oracle的表的數據管理1 -- 增刪改

 添加數據

1.      插入全部的字段session

a.      按照表格的字段數據進行添加oracle

b.      添加的數據必須符合字段的數據類型要求spa

c.      在oracle中,添加日期數據格式爲‘DD-MON月-YY’,其中mon月份必須帶上‘月’字日誌

d.      能夠修改日期的默認格式:alter session set nls_date_format =‘yyyy-mm-dd’;orm

SQL>insert into student values(1,'小明','n','22-5月-88','2000.20','1');ci

1 rowinsertedio

2.      插入部分字段table

SQL>insert into student(xh,sex) values (‘A002’,’女’);form

3.      插入空值date

SQL>insert into student(xh,xm,sex,birthday) values (3,'小黃','na',null);

1 rowinserted

SQL>select * from student where birthday isnull;

   XHXM                            SEX BIRTHDAY         SAL CLASSID

----------------------------------- --- ----------- ----------------

   3 小黃                           na                       

修改數據

1.      修改一個字段的數據

Update student setsex=’nv’ where xh=’A001’;

2.      修改多個字段的數據

Update student setsex=’na’,birthday=’1988-05-22’ where xh=’A001’;

3.      修改含有null值的數據

同上:Is null;

 刪除數據

1.      刪除表內所有數據

SQL>delete from student;

 

2.      恢復數據

a.      設局設置保存點

SQL>savepoint a;

b.      回滾到保存點

SQL>rollback a;

3.      刪除表的結構和數據

Drop table student;

4.      刪除單條記錄

Delete fromstudent where xj=’A001’;

5.      刪除表中全部數據

Truncate tablestudent;

注: 與delete 不一樣,他一樣也刪除表中全部數據,但不記錄日誌,因此沒法恢復,但速度極快。經常使用於數據量較大,並且已經徹底決定不用的表的刪除管理。
相關文章
相關標籤/搜索