一、rowid
二、select * from tab;
drop table testdelete;---刪除以后會刪到oracle的回收站
show recyclebin;---查看回收站
purge recyclebin;---清空回收站
如果drop掉一個表,如何訪問?-----select * from ?"被刪除的表在回收站的表名"; ? 注意加引號
三、oracle中管理員沒有回收站
--show user?
conn sys/password@192.168.56.101:1521/orcl as sysdba;---管理員
create table test1(tid ?number);?
drop table test1;
show ?recyclebin; ?回收站為空
-------如何把表從回收站中取出來?“閃回”
----drop table 不能回滾,但是可以閃回
四、約束
約束是表一級的限制
如果存在依賴關(guān)系,約束可以防止錯誤的刪除數(shù)據(jù)
約束的類型:not null ; unique; ?primary key ; foreign key ; check
例子:
create table test3
(tid number,
tname varchar2(20),
gender varchar2(2) ?check (gender in ('男','女')),
sal number check (sal<0)
);
通過主鍵查最快,因為unique是唯一性的索引
foreign key:在字表中,定義了一個表級的約束
references:指定表和父表中的列
on delete cascade:當刪除父表時,級聯(lián)刪除字表記錄
on delete set null:將字表的相關(guān)依賴記錄的外鍵值置為null----一般用這個,數(shù)據(jù)不易丟失
create table student?
(
sid number constraint student_PK primary key,
sname varchar2(20) constraint student_name_notnull not null,
gender varchar2(2) constriaint student_gender_cheek (gender in ('男','女')),
email varchar2(20) constriaint student_email_unique unique?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?constriaint student_email_notnull ?not null,
deptno ?number ?constraint ?student_fk references dept(deptno) on delete set null
);