15.1.1 插入完整行
insert
into customers
values
('100'
,'toy'
,null
);
insert
into customers(cust_id,
cust_name,
cust_email)
values
('100'
,'toy'
,null
);
注意⚠️:
1、可以保證在值與列的對應。
2、values的數目必須與列數對應!
15.1.2 插入部分行
insert
into customers(cust_id)
values
('100'
);
省略了must_name, cust_email。
注意⚠️:
可以省略列的條件:
1、允許null
2、或者在表的定義中給出了預設值
15.1.3 插入檢索出的資料
insert
into customers(cust_id,
cust_name,
cust_email)
select cust_id,
cust_name,
cust_email
from custnew;
把select的資料,插入到表中。
注意⚠️:
1、只關心查詢返回的列的位置,而不關心列名。
2、可以一次性插入多行(一般insert一次只能插入一行)
update customers
set cust_contact =
null
, cust_email =
where cust_id =
'100'
;
更新為null,即表示刪除該列的值。
注意⚠️:null不同於』'
delete form customers
where cust_id =
'100'
;
注意⚠️:
1、刪除的是行。
2、有外來鍵可以防誤刪。
3、想要刪除全部行,用truncate table更快。
《SQL必知必會》學習筆記
資料庫管理系統 dbms 資料庫軟體。資料庫 database 儲存有組織的資料的容器。通過dbms建立和操縱的容器。表 table 用於儲存某種特定型別資料的結構化檔案。模式 schema 關於資料庫和表的布局及特性的資訊。列 column 表中的乙個字段。表是由乙個或多個列組成的。行 row 表...
SQL必知必會學習筆記
2.檢索資料 3.排序檢索資料 4 過濾資料 5.高階資料過濾 5.2in操作符 5.3not操作符 6.用萬用字元進行過濾 轉行的辛酸。加油!儲存有組織的資料的容器 某種特定型別資料的結構化清單 儲存在表中的資料是同一種型別的資料或者清單 表名是唯一的 表由列組成。列儲存表中某部分的資訊 列 co...
《sql必知必會》筆記
資料庫 儲存有組織的資料的容器 通常是乙個檔案或一組檔案 注意誤用混淆 資料庫軟體被稱為dbms,資料庫是通過dbms建立和操縱的容器 模式 關於資料庫和表的布局及特性的資訊。主鍵 一列或一組列,其值能夠唯一標識表中的每一行。多條sql語句必須以 分隔。sql語句不區分大小寫,select和sele...