mysql 必知必會2 資料操作語言DML

2021-10-06 22:27:48 字數 1322 閱讀 3345

規則: 插入值的型別要一致

insert into 表名(列名) values ( 值1...)

insert into 表名 set 列名1=值1,列名2=值2

123

4567

891011

1213

1415

1617

1819

2021

2223

2425

2627

2829

3031

32

#  插入 insert

# 插入完整行,或者部分

insert into customers(

cust_name,

cust_address,

cust_city,

cust_state)

values(

'elgong',

'1552460315',

'hangzhou',

'1');

# 插入多行

insert into customers(

cust_name,

cust_address,

cust_city,

cust_state)

values(

'elgong',

'1552460315',

'hangzhou',

'1'),

('gel',

'178905324',

'hangzhou',

'0');

123

456

#  更新 update  set

# 更新某行的某些列值

update customers

set cust_email = "[email protected]", # 列1

cust_name = "elgong"

where cust_id = 1;

3. 刪除

刪除整行

123

4567

#   刪除

# 刪除特定行

delete from customers where cust_id=1;

# 刪除所有行

delete from customers ;

truncate table;

mysql必知必會 mysql必知必會(四)

十四 理解子查詢 1 通過子查詢過濾 這本書在所有的章節都關連到了資料庫表,訂單資料是儲存在兩個表中,orders表儲存著 訂單號碼 顧客id和訂單日期。個人的訂單列表關連著orderitems表,訂單表沒有儲存顧客資訊,它只是儲存著顧客id,這實際的顧客資訊是儲存在customers表中。現在假設...

mysql的必知必會 mysql 必知必會 筆記

好久沒有寫了。1 show columns from table 等同於describe table顯示的是表的結構。而select from table 則顯示的是整個表中插入的資料。2 select distinct c1,c2 from table除非列不相同,否則所有行將被檢索出來,即不能對...

《MySQL必知必會》總結2

1.從內往外,查到的值作為條件輸入 2.相關子查詢,涉及到列名有多義性,需要用完全限定列名,如orders.cust id 3.建立計算字段,並命名為orders select cust name,select count from orders where orders.cust id custo...