插入
插入完整的行
insert into customers values
(
'10000006',
'Toy Land',
'123 Any Street',
'New York',
'NY',
'1111',
'USA',
null,
null
);
複製程式碼
更規範的寫法:
insert into customers
(
cust_id,
cust_name,
cust_address,
cust_city,
cust_state,
cust_zip,
cust_country,
cust_contact,
cust_email
)
values
(
'10000007',
'Toy Land',
'123 Any Street',
'New York',
'NY',
'1111',
'USA',
null,
null
);
複製程式碼
插入部分資料
insert into customers
(
cust_id,
cust_name,
cust_address,
cust_city,
cust_state,
cust_zip,
cust_country
)
values
(
'10000008',
'Toy Land',
'123 Any Street',
'New York',
'NY',
'1111',
'USA'
);
複製程式碼
插入檢索出的資料
insert into customers
(
cust_id,
cust_name,
cust_address,
cust_city,
cust_state,
cust_zip,
cust_country
)
select
cust_id,
cust_name,
cust_address,
cust_city,
cust_state,
cust_zip,
cust_country
from custnew;
複製程式碼
從一個表複製到另一個表
create table custcopy as
select *
from customers;
複製程式碼
更新資料
update語句有三部分組成:
- 更新的表
- 列名和值
- 確定更新行的過濾條件
update customers
set cust_email = null
where cust_id = '111111110';
複製程式碼