您的位置:首页 > 数据库

SQL学习—INSERT、UPDATE、DELETE语句

2017-10-03 21:09 549 查看

SQL之INSERT、UPDATE、DELETE总结

一、数据插入

1、插入完整行

INSERT INTO Cusomers
VALUES('100006','Toy Land','123 Any Street','New York','NY','1111',NULL,NULL);

INSERT INTO Cusomers (cust_id,cust_name,cust_address,cust_city,cust_state,cust_zip,cust_contact,cust_email)
VALUES('100006','Toy Land','123 Any Street','New York','NY','1111',NULL,NULL);


2、插入部分行

INSERT INTO Cusomers (cust_id,cust_name,cust_address,cust_city,cust_state,cust_zip)
VALUES('100006','Toy Land','123 Any Street','New York','NY','1111')


3、插入检索出的数据

INSERT INTO Cusomers (cust_id,cust_name,cust_address,cust_city,cust_state,cust_zip)
SELECT cust_id,cust_name,cust_address,cust_city,cust_state,cust_zip FROM CustNew


4、从一个表复制到另一个表(要想只复制部分列,可以明确给出列名)

SELECT * INTO CustCopy FROM Customers


二、更新数据

UPDATE Customers
SET cust_contact='Sam Reberts',cust_email='sam@toyland.com' WHERE cust_id='1000006'


三、删除数据

DELET FROM Customers WHERE cust_id='1000006'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: