Modify data table name and column name
Modify column names
alter table [table_name] change [old_column_name] [new_column_name] [data_type]
- Only change the column name: data_type is the same as before, old_column_name !=new_column_name, data_type remains unchanged
- Only change the data type: old_column_name = new_column_name , data_type changed
- Both column names and data types are changed: as shown in the code
Modify table name
alter table [table_name] rename [new_table_name]
example:
alter table account rename newaccount
Where's in operator use
select *from 表名 where 列名 in (value1,value2 ...)
select *from 表名 where 列名 in (select 列名 from 表名)
annotation:
column name in (value1, value2...) is equivalent to column name = value1 or column name = value2...
select distinct (exact)
select distinct col_name from table_name ;
example
select distinct title from book
insert into is used in combination with select
General usage:
insert into [表名] values(值1,值2, ...)
insert into [表名] (列1,列2 ... )values(值1,值2,...)
The combined usage of Insert into and select
insert into [表名1] select 列1,列2 from [表名2]
insert into [表名1] (列1,列2) select 列3,列4 from [表名2]
The between operator in the where statement (between... )
select *from 表名 where 列名 between 值1 and 值2
select *from 表名 where 列名 not between 值1 and 值2
like operator
select *from 表名 where 列名 [not] like pattern
pattern: matching pattern, such as: 'abc', '%abc', 'abc%', '%abc%';
'%' is a wildcard, it can be understood as any string
example
'%abc' matches 'ettrabc'