Open mysql: mysql -hlocalhost -uroot -p123456
database operation
operate | Order |
---|---|
Build database | Create database name |
Uninstall library | Drop library name |
Show all tables in a library | Show databases |
Select a library to operate | Use library name |
table operation
operate | Order |
---|---|
create table | create table table name (attribute char(4) PRIMARY KEY, attribute varchar(50)not null) |
Show all tables in the library | Show tables |
show a table | Describe table name |
table rename operation | alter table original name rename to new name |
Column rename operation (column is empty) | alter table table name rename column A to B data type |
Add value (multiple values can be added) | insert into table name (field name 1, field name 2, ...) values (value 1, value 2, ...), (···), (···); |
Delete a row of data in the table (delete the entire table when there is no where) | delete from table name where field name=value; self-increment field does not return to 0 |
Delete the data in the table (no where), and return the auto-increment field to 0 | truncate table table name |
drop a table | drop table table name |
Update some data (no where, all updates) | update table name set field name 1 = value 1, field name 2 = value 2 where conditional expression |
Modify column properties | alter table table name modify column field name type |