//创建数据库 create databases name; //选择数据库 use databasename; //删除数据库,不提醒 dropdatabase name; //显示所有表 show tables; // 表的详细描述 describe tablename; //显示创建表的SQL语句 showcreatetable table_name; //当前数据库版本 select version(); //查看数据库编码 SHOW VARIABLES LIKE'character%'; //查看表字段和注释 showfull columns from table_name;
2、查询命令
//查看表全部内容 select * from table_name //查看表中id=1的内容 select * from table_name where id = '1'; //排序 select * from table_name orderby id desc; //分组 select * from table_name groupby age ; //分组统计 selectcount(*) from table_name groupby age; //查询一条数据 select * from table_name limit 1; //分页 select * from table_name limit 10,10 //左连接 select * from table_name as t1 leftjoin table_name_2 as t2 on t1.id=t2.t_id; // select * from table_name unionall (select * from table_name_2)
插入修改命令
//批量插入数据 insertinto table_name (field1,field2) values(1,2),(2,2),(3,2) //修改 update table_name set field=valuewhere id =1; //删除表内容 deletefrom table_name; deletefrom table_name where id =1;