mysql常用语句
来源:互联网 发布:韩顺平javascript 编辑:程序博客网 时间:2024/05/16 06:53
基本语句
(获取数据库详情) select * from information_schema.SCHEMATA where SCHEMA_NAME = “dbName”; 进入数据库 use dbName; 显示所有表 show tables; 查看表结构 describe 表名; 查看表详细定义 show create tables tableName; 创建表 create table 表名 (字段名 类型 约束, 字段名 类型 约束,设置外键 …) 约束 primary key / auto_increment / unique / not null / default ‘张三’ 主键和自动增长一起使用 设置外键 foreign key (当前表外键名) references fkTbaleName(primaryKey) 设置外键(定外键名) constraint fkName foreign key (当前表外键名) references fkTbaleName(primaryKey) 删除外键约束 alter table tableName drop foreign key fkName 删除表 drop table 表名 如果表存在则删除 drop table if exists class 插入数据 insert into 表名(字段,…) values (数据,…); 清空数据 delete from tableName 有日志 清空数据 truncate table tableName 无日志 修改表名 alter table tableName rename newTbaleName 修改字段名 alter table tableName change oldFiledName newFiledName 类型 [约束] 修改字段类型/约束 alter table tableName modify filedName 类型 [约束] 增加字段 alter table tableName add filedName type [constraint] [first or after filedName] first–>首位 after filedName–>某字段后面 删除字段 alter table tableName drop filedName 修改字段排序位置 alter table tableName modify filedName type [constraint] first [or after filedName] 查询数据 select * from tableName todo 复杂查询
0 0
- 【MySQL】常用MySQL语句
- MySql常用语句
- mysql常用语句
- mysql常用语句集锦
- MySQL常用操作语句
- mysql常用语句
- mysql 常用修改语句
- mysql常用SQL语句
- MYSQL常用语句
- MySQL常用语句
- MySQL常用操作语句
- mysql常用语句
- 常用的mysql语句
- mysql常用SQL语句
- 常用mysql语句备忘
- 常用mysql语句备忘
- mysql常用语句
- 常用mysql 命令语句
- numpy生成数组的零值问题
- 初识HTML的结构
- Java中重载和重写,多态几个概念之间的区别
- LeetCode刷题记录Easy篇(1)
- 树莓派+ 步进电机
- mysql常用语句
- Windows多媒体定时器(精确到1ms) (二)
- mysql主从配置
- POJ2524 Ubiquitous Religions (并查集)
- struts2基础学习收录重点之OGNL动态配置result , 使用注解配置action,实现java国际化
- 支付宝支付之从前台打通到后台(二)
- java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ‘name pattern’
- dp---跳跃游戏
- vim配置