文档详情

oracle SQL资料整理.doc

发布:2017-08-02约1.47万字共14页下载文档
文本预览下载声明
-- 一,資料定義語言(Database Definition Language) --/ ***************************** TABLE ***************************************************************/ -- 1 table create table school (sid char(6), name varchar2(20)); create table schoolmaster (nid char(6), name varchar2(20), sid char(6), sex char(1) ); create table school_temp as select * from school; primary key -- constraint pk_school primary key(sid) foreign key -- constraint fk_school_schoolmaster foreign key (sid) references school(sid) check -- constraint ch_schoolmaster_sex check(sex in(1,2) or sex = null)) check(列名字 between and ) default -- name varchar2(200) defaultSUPER comment on table school is 學校檔; comment on column school.sid is 學校sid; -- 2,alter table add modify drop alter table schoolmaster add(age number ); ------ 創建 check 約束 alter table schoolmaster add constraint schoolmaster check (sex in (1,2)); select * from test_02 ---- 設置 主KEY alter table test_02 add constraint pk_test_01 primary key(t_id,t_no) ---- 增加列 alter table test_02 add ( t_nm char(10), t_coin number(4)) --- 修改 列 alter table test_02 modify ( t_nm char(20), t_coin number(4) not null) ---- 刪除 列 alter table test_02 drop (t_no,t_nm) --- 刪除 主KEY 列 alter table test_02 drop column t_no cascade constraint -- 3,drop table drop table schoolmaster; -- 4,index create unique index index_name on table_name(column_name1,column_name2) tablespace index nologging --提高速度. 不向redo日志文件記錄索引工作 nosort --如已經被預先排序 online --建立索引時候 用戶可以訪問表 compute statistics --維護其當前的統計數據 不能跟online一起使用 不能自動維護, 需要用到 analyze table命令 --
显示全部
相似文档