Simple operation of database_add, delete, modify and check replicated tables

1. Increase (insert)

1. Commonly used

insert into 表名 values(v1,v2.....);

Insert picture description here
Insert picture description here

2. Add specified fields

insert into 表名[(字段1 ...)] values(v1 ....);

Insert picture description here

Two, delete (delete)

1.delete from 表名 where 条件;

Insert picture description here
2. Note: .truncate statement (use with caution) This statement is also used to delete the table and cannot be recovered

truncate table 表名;

Three, modify (update)

update t_name set 字段1 = 新值, 字段2 = 新值 ...  where 条件 ;

Insert picture description here

Four, search (select)

The result of the query is also a virtual table
1. View all the contents of the table

select * from 表名;

Insert picture description here
2. Look up the specified field in the table

select 字段1,字段2.... from 表名;

Insert picture description here

Five, simple modification to the table (alter table)

1. Add new fields

alter table 表名 add 字段名 字段类型 约束条件;

Insert picture description here
2. Modify the field type

alter table 表名称 modify 字段名 字段类型;

Insert picture description here
3. Modify the field name

alter table 表名称 change 旧字段名 新字段名 字段类型;

Insert picture description here
4. Modify the table name

1.alter table 旧表名 rename 新表名;
2.rename table 旧表名 to 新表名;

Insert picture description here
Insert picture description here

Six, copy of the table

1.create table 新表名 like 源表;
2.create table 新表名 select * from 源表;

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44913154/article/details/108912031