常見oracle數(shù)據(jù)對象
用戶
角色
表空間
數(shù)據(jù)表
索引
視圖
序列:數(shù)據(jù)的計數(shù)器
同義詞:為數(shù)據(jù)表取別名
存儲過程:
函數(shù):
觸發(fā)器:’
程序包:上面三個的集合
數(shù)據(jù)庫定義語言DDL:主要對數(shù)據(jù)庫對象的創(chuàng)建、刪除和修改。
1、create 語句創(chuàng)建數(shù)據(jù)表

2、alter 語句
alter table table_name ADD column_name column_type;
alter table table_name MODIFY?collumn_name clolumn_type;
alter table table_name DROP COLUMN column_name;
3、drop語句刪除數(shù)據(jù)表
DROP TABLE table_name;
4、添加主鍵約束
方式1:創(chuàng)建表時添加主鍵約束
方式2:創(chuàng)建表后添加主鍵約束
ALTER TABLE table_name ADD CONSTRAINTES constraint_name PRIMARY KEY(column_name);
5、聯(lián)合主鍵(跟樓上一樣)
6、外鍵約束
一張表的某一列的值來自另一張表的主鍵列
1.創(chuàng)建表時并創(chuàng)建外鍵約束
constranit 外鍵名 foreign key(這張的列) references 參考表(列明)
create table score(
scoreID int ,
stuID int ,
score int ,
courseName varchar2(20) not null,
constraint fk_stuId foreign key(stuID) references student(stuID)
);
2.表創(chuàng)建成功后再添加外鍵約束
--添加外檢約束 :alter table 從表表名 add constraint 外鍵約束名稱 foreign key(列名) references 主表名稱(主鍵列名)
alter table score add constraint ck_stuID foreign key(stuID) references student(stuID);
7、check約束
7.1 創(chuàng)建表時:constraint con_name CHECK(約束條件)
constraint ck_student_sex CHECK(stu_sex='男' or stu_sex=‘女’);
7.2修改表時:ALTER TABLE table_name ADD CONSTANINTS con_name CHEKC(約束條件)
刪除check約束:
ALTER TABLE table_name DROP CONSTRAINTS con_name;
8、unique約束:唯一鍵約束
8.1 CONSTRAINT con_name UNIQUE(column_name);
stu_tel char(11) unique;
8.2 ALTER TABLE table_name ADD CONSTRAINTS con_name UNIQUE(column_name)
刪除UNIQUE約束:
ALTER TABLE table_name DROP CONSTRAINTS con_name;