forked from grb2015/sql
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path016.update_del.sql
More file actions
32 lines (22 loc) · 1.1 KB
/
016.update_del.sql
File metadata and controls
32 lines (22 loc) · 1.1 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
26
27
28
29
30
31
USE `sqlin10mins`;
-- 修改表中的数据。删除/增加表中的某一行/列
-- update: 给100000005增加电子邮件
update Customers set cust_email='kim@thetoystore.com' where cust_id = '1000000005';
-- 取消给100000005增加电子邮件
update Customers set cust_email=NULL where cust_id = '1000000005';
-- delete 删除100000006这一行
delete from Customers where cust_id = '1000000006';
-- 1.清空表中数据
-- delete from `12_company_info` where 1;
-- 这里的1表示true.
-- 2.如果要删除指定的行号的某行,mysql由于无法直接得到行号,所以还不太好操作
-- 增加一列
create table vendors_copy as select * from Vendors;
alter table vendors_copy add vend_phone char(20);
-- 删除一列
alter table vendors_copy drop column vend_phone;
-- 补充1:
-- 要设置某一列的值为1,
-- UPDATE `jcimate_alarm_rules`.`tbl_attribute` SET `complex_operate_id`='1'
-- 需要注意的是,Mysql中必须跟一个where条件,不然会说不安全而报错,要取消报错可以运行下面的:
-- SET SQL_SAFE_UPDATES=0;