Oracle資料庫,資料的增、刪、改、查

來源:互聯網
上載者:User

標籤: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資料庫,資料的增、刪、改、查

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.