MySQL技巧#常用MySQL数据库命令总结
来源:互联网 发布:长春典恒网络发展有 编辑:程序博客网 时间:2024/05/17 03:47
1、MySQL常用命令
//创建数据库create databases name;//选择数据库use databasename;//删除数据库,不提醒drop database name;//显示所有表show tables;// 表的详细描述describe tablename;//显示创建表的SQL语句show create table table_name;//当前数据库版本select version();//查看数据库编码SHOW VARIABLES LIKE 'character%';//查看表字段和注释show full columns from table_name;
2、查询命令
//查看表全部内容select * from table_name //查看表中id=1的内容select * from table_name where id = '1';//排序select * from table_name order by id desc;//分组select * from table_name group by age ;//分组统计select count(*) from table_name group by age;//查询一条数据select * from table_name limit 1;//分页select * from table_name limit 10,10//左连接select * from table_name as t1 left join table_name_2 as t2 on t1.id=t2.t_id;//select * from table_name union all (select * from table_name_2)
插入修改命令
//批量插入数据insert into table_name (field1,field2) values(1,2),(2,2),(3,2)//修改update table_name set field=value where id =1;//删除表内容delete from table_name;delete from table_name where id =1;
表结构修改
//删除表drop table table_name;//增加一个字段alter table table_name add column(字段名 字段类型)//指定插入位置alter table table_name add column(字段名 字段类型) after 某字段//删除一个字段alter table table_name drop 字段名//修改字段名称/类型alter table table_name change 旧字段名 新字段名 新字段类型//修改表名称alter table table_name rename to new_table_name;//清空表truncate table table_name;
0 0
- MySQL技巧#常用MySQL数据库命令总结
- 常用mysql数据库操作命令总结
- Mysql常用技巧总结
- Mysql常用技巧总结
- 常用MySQL数据库命令
- 常用MySQL数据库命令
- 常用mysql命令总结
- Mysql数据库命令总结
- mysql数据库常用cmd命令
- mysql常用操作命令总结
- MySql常用操作命令总结
- MySQL常用基本命令总结
- MySQL数据库常用操作总结:
- MYSQL数据库SHOW命令 总结
- MySQL数据库常用操作和技巧
- MySQL数据库常用操作和技巧
- Mysql 原理,命令,及技巧总结
- Mysql 原理,命令,及技巧总结
- 使用gitolite管理git权限
- Lua查找表元素过程(元表、__index方法是如何工作的)
- Spring事物设置回滚点
- 重写已被弃用的Gallery
- Unity3D 快捷键
- MySQL技巧#常用MySQL数据库命令总结
- Java环境配置
- 蓝桥杯算法训练——2的次幂表示 (递归)
- html网页css的三种引入方式
- 数据结构--最小生成树详解
- linux定时备份MySQL数据库并删除七天前的备份文件
- 查看mysql数据库及表编码格式
- 管脚复用
- 谈谈 iOS 中图片的解压缩