oracle常用操作

2021-08-27 07:11:39 字數 1097 閱讀 7700

刪除索引:

drop index pk_fsoreplan

刪除主鍵:

alter table fsoreplan drop constraint pk_fsoreplan

刪除外來鍵:

alter table tablea_tableb drop constraint fk_ab

建立主鍵:(多個主健一起建立)

alter table fsoreplan add constraint pk_fsoreplan primary key (repolicyno,reendorno, repayno, serialno, reinsmode,belongtype,paytype);

注:fsoreplan 是表名,pk_fsoreplan 是主鍵名,fk_ab是外鍵名;

1、建立表的同時建立主鍵約束

(1)無命名

create table student (

studentid int primary key not null,

studentname varchar(8),

age int);

(2)有命名

create table students (

studentid int ,

studentname varchar(8),

age int,

constraint yy primary key(studentid));

2、刪除表中已有的主鍵約束

(1)無命名

可用 select * from user_cons_columns;

查詢表中主鍵名稱得student表中的主鍵名為sys_c002715

alter table student drop constraint sys_c002715;

(2)有命名

alter table students drop constraint yy;

3、向表中新增主鍵約束

alter table student add constraint pk_student primary key(studentid);

oracle 常用操作

表空間test1 create tablespace test1 datafile d oracledabase test1.dbf size 30m autoextend on next 30m maxsize unlimited logging extent management local 使...

Oracle常用操作

1 資料庫匯入匯出命令 exp 使用者名稱 密碼 192.168.2.121 1521 orcl file d 123.dmp log d 123.log exp 使用者名稱 密碼 192.168.2.121 1521 orcl file d 123.dmp full y 3 限制ip訪問資料庫 1...

Oracle 常用操作

連線數 sql select count from v session 當前的連線數 sql select count from v session where status active 併發連線數 sql select value from v parameter where name proc...