標籤:class tab not null oracle資料庫 語言 span 技術分享 擷取
oracle資料庫中,資料的增、刪、改、查,通過SQL語句實現
SQL:結構化查詢語言 (SQL);
特點:不區分大小寫;字串用單引號引起來;語句結束用分號表示結束;
行注釋,在語句的最前面加“--”
塊注釋,分別在語句的前後加 /* 和 */
SQL中常用的幾類:
一、資料定義語言 (Data Definition Language) DDL:建立、修改、刪除資料庫語言。
create table Student( sno varchar2(3) not null, sname varchar2(8) not null, ssex varchar2(2) not null, sbirthday date, sclass varchar2(5));-- Add comments to the table comment on table Student is ‘學生表‘;-- Add comments to the columns comment on column Student.sno is ‘學號(主建)‘;comment on column Student.sname is ‘學生姓名‘;comment on column Student.ssex is ‘性別‘;comment on column Student.sbirthday is ‘生日‘;comment on column Student.sclass is ‘班級‘;
二、資料操作語言 DML:添加(insert into)、修改(update set)、刪除表中的資料。(delete)
1.資料的添加:
--增加資料insert into student(sno,sname,ssex) values(‘102‘,‘張三‘,‘男‘);--或者這樣寫insert into student values(‘102‘,‘張三‘,‘男‘,sysdate,‘95033‘);select * from student
2.資料的修改:
--資料的修改update student set ssex=‘女‘ where sno=‘102‘;--如果不加where,便是修改整個表某列的屬性--對某一列資料的加減update student set sclass=sclass+1;update 表名 set 列名=列名+1 where 條件--日期的加減1為日的加減1
3.資料的刪除:
--資料的刪除delete student where sno=102;delete 表名 where 條件;--不加where,即刪除整個表,但是效率低,可用truncate table 表名來刪除(先刪表,再建表)例:truncate table student;
三、資料查詢語言 DQL:從表中擷取資料(查詢資料)。
--資料查詢select * from student;select * from 表名;--根據條件找欄位select sno,sname from student where sclass=‘95031‘;select 欄位名 from 表名 where 條件
Oracle資料庫,資料的增、刪、改、查