Mysql基本语句
来源:互联网 发布:hp1005扫描软件下载 编辑:程序博客网 时间:2024/06/11 05:49
1. 在safe-updates模式下,该模式会导致非主键条件下无法执行update等
SET SQL_SAFE_UPDATES = 0
2. 创建表
create table common.qc_question( qc_type int(10) NOT NULL, qc_id int NOT NULL AUTO_INCREMENT, qc_describe VARCHAR(1255) NOT NULL, qc_answer VARCHAR(255) NOT NULL, PRIMARY KEY ( qc_id ) );
3. 查询所有数据
select * from common.qc_question
4. 清空表的内容
truncate table common.qc_question
5. 随即获取n组数据
select qc_describe,qc_answer from common.qc_question where qc_type = 1 and qc_id >= (select floor( max(qc_id) * rand()) from test_qc.qc_question ) order by qc_id limit n
6. 自增数据查询(防止查询到以前查过的数据)
select qc_id,qc_describe, qc_answer from common.qc_question where qc_type = 1 limit 2 offset n*2(n为请求的次数)
7. 插入数据
insert into common.question values(qc_type,null,"qc_describe","qc_answer")
8. 指定自增的字段从某一个序号开始
alter table qc.qc_question AUTO_INCREMENT=55;
9. 按照指定条件删除的数据
delete from qc.qc_question where qc_id >= 55
10 向表中添加新的字段
alter table table1(表名) add transactor(字段名字) varchar(10) not Null
11 向表中添加索引
alter table test.test1 add index index_test1(uid) :index_test1为索引的别名 create index index_test2 on test.test1(trans) : index_test2为索引的别名
12 添加主键
Alter table tb add primary key(id);
13 获取系统当前时间:now()
阅读全文
0 0
- mysql基本语句
- mysql基本语句
- mysql基本sql语句
- mysql操作基本语句
- MySQL基本SQL语句
- MYSQL 基本语句
- mysql基本语句
- mysql基本语句
- mysql基本语句大全
- Mysql基本语句练习
- mysql 基本语句
- MySQL的基本语句
- mysql基本语句
- MySQL基本SQL语句
- mysql基本语句1
- MySQL基本语句总结
- MySQL 基本操作语句
- MySQL基本语句
- linux 安装FTP 设置ftp用户登入
- TP5 函数助手实例说明
- 网际层(Internet)
- spring cloud 之 zuul
- 只在堆上或是栈上分配对象的方法:
- Mysql基本语句
- eclipse中显示行号
- 关于Delaunay triangulation那些事
- Web基础之Servlet+JDBC+JSP项目实战终结篇
- Redis-主从复制,读写分离,主从切换
- 学习随笔—`malloc.h`内存申请头文件
- MT6735 alsps驱动P/L sensor问题
- 计算机网络基础知识
- 学习JAVA线程池