Operating table data MySQL_

1. Add data

insert into <表名>[<字段名>[,...]]
values(<常量>[,...]);
insert into 表名(字段名1,字段名2)
values('2015','男');
//可以选择性输入,但是主键必须输入
insert into 表名
values('数据1','数据2');
//此方法,必须输入所有字段

2. Add the pieces of data

insert into 表名
values(),();

3. Update Data

update<表名>
set<字段名>=<表达式>[,...]
[where<条件>];

For example: The birth date changed to 1995-02-01 Zhang Wenjing

update 表名
set 出生日期='1995-02-01'
where 姓名='张文静';
  • All data in the field changes change
update 数据表名
set 成绩=成绩*0.6;

4. Delete Data

1. The specific records

delete from<表名>
[where<条件>];
delete from 表名
where 姓名='张文静';

2. Delete all records in the table

truncate table<表名>;
delete from 表名;

3. To delete the data table, then re-create the original tables, data loss, the same type of field

truncate table 表名;

4. Delete Data Sheet

drop table [if exists] 表1,表2;

5. Review the data table

select *from 表名

Guess you like

Origin www.cnblogs.com/ninebook/p/12002021.html