-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path15_insert.sql
More file actions
32 lines (16 loc) · 1.2 KB
/
15_insert.sql
File metadata and controls
32 lines (16 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
--- 数据库的增删查改,我们之前一直在学习'查',现在来学习'增'
---请在customers表中增加一行数据,有新的顾客来了!但是它没有提供cust_country,cust_contact和cust_email项
insert into Customers(cust_id ,cust_name,cust_address, cust_city, cust_state,cust_zip)
values('1000000006', 'Toy Land','123 Any Steet','New York', 'NY', '11111');
---rbguo 2018513 added
---插入多行数据:
insert into table_name(col1,col2...) values (col1,col2,...),(col2,col2,...)
--- 插入检索出的数据 --现需要将另一表CustNew中的顾客合并到customers中.
insert into Customers(cust_id,cust_city,cust_name,cust_state,cust_address,cust_email,cust_contact) select (cust_id,cust_city,cust_name,cust_state,cust_address,cust_email,cust_contact)from CustNew;
--- 复制表 请复制Customers表,命名为CustCopy
select * into CustCopy from Customers;
--mysql中使用
create table CustCopy as select * from Customers;
--- 如果只想复制部分列,可以明确给出列名
select cust_city,cust_contact,cust_id into CustCopy from Customers;
create table CustCopy_2 as select cust_city,cust_contact,cust_id from Customers;