连接数据库: mysql -u<username> -p<password>;
显示所有数据库:mysql> show databases;
选择数据库:mysql> use <database name>;
创建一个数据库:mysql> create database <database name> [charset <charset>];
删除一个数据库:mysql> drop database <database name>;
修改数据库名:mysql无法直接修改数据库名!
显示所有表:mysql> show tables;
删除一张表:mysql> drop table <table name>;
修改表名:mysql> rename table <table name> to <new table name>;
清空表:mysql> truncate <table name>;
快速建一张相似的表:mysql> create table <table name> like <another table>;
查看建表语句:mysql> show create table <table name>;
插入所有字段数据:mysql> insert into <table> values(v1,v2,v3...vn);
修改语句:mysql> update <table> set <filed1=v1> where <expression>;
删除语句:mysql> delete from <table> where <expression>;
删除所有数据:mysql> delete from <table>;
增加一列:mysql> alter table <table> add <field> <type> [other] '';
在某列后增加一列:mysql> alter table <table> add <field> <type> [other] after <field1>;
添加到第一列:mysql> alter table <table> add <field> <type> [other] first;
删除某一列:mysql> alter table <table> drop <field>;
修改某一列的参数:mysql> alter table <table> modify <field> <type> [other];
修改列名(必须带上参数):mysql> alter table <table> change <old field> <new field> <type> [other];
①.增加一列:mysql> alter table <table> add <field> <type> [other] '';