sql大資料 基礎(DML資料操縱語言)

2021-10-10 01:25:13 字數 1376 閱讀 6373

dml 資料操縱語言

select 增刪改

insert into +表名(列1,列2…) values (值1,值2…);

如果沒有賦值的列則為空

insert into +表名 values (值1,值2…);

預設對錶內所有字段新增資料

select * from sc;

insert into sc values (『s099』,『c099』,60);

select * from student;

insert into student(sno,sname) values (『s099』,『小明』);

練習: 將小張老師加入教師表

insert into teacher values (『t099』,『小張』);

select * from teacher;

快捷插入

insert into student (sno,sname) select empno,ename from scott.emp ;

update 表名

set 列名 = 新值

[where 條件];

注:如果沒有where條件則預設全表資料修改

update student set sage = 25 where sno = 『7499』;

update student set sage = 25,s*** = 『男』 where sno = 『7499』;

select * from student where sno = 『7499』;

練習:將員工表smith的工資漲2000

update scott.emp set sal = sal+2000 where ename = 『smith』 ;

將員工表allen,smith的工資漲2000

update scott.emp set sal = sal+2000 where ename in ( 『smith』 ,『allen』);

空值update student set s*** = null where sno = 『7499』;

delete from 表名 [where 條件]

注:如果不加where條件則預設刪除全表資料

delete from student where sno = 『s099』;

select * from student;

delete from student where sno in (select to_char(empno) from scott.emp);

SQL基礎4 DML資料操縱語言

關鍵字 insert uodate delete truncate 語法 insert into 表名 欄位1 欄位2.values value 值1,值2.方式1 直接插入 insert into 表名 欄位1 欄位2.values 值1,值2.值1,值2.方式2 從其他列表插入 insert i...

DML 資料操縱語言

資料操縱語言dml主要有三種形式 語法insert into 表名 列名1,列名2,列名n values 值1,值2,值n 注意 列名和值要一一對應。如果表名後,不定義列名,則預設給所有列新增值 insert into 表名 values 值1,值2,值n 除了數字型別,其他型別需要使用引號 單雙都...

資料庫學習 SQL的資料操縱(DML)

常用的資料操縱dml關鍵字 insert delete update insert有兩種形式 1 插入單個元組 insert into 表名 屬性名清單 values 元組值 insert into s xh,xm,xb,csrq,jg,sjhm,yxh values 1101 李明 男 1993 ...