찾다

早打算写些关于数据库操作方面的知识了,现在终于完成了第一篇,以下记录了关于mysql操作方面的基础知识

在window下,启动、停止mysql服务

启动mysql数据库
net start mysql

停止mysql数据库
net stop mysql

重新启动mysql数据库
net restart mysql


命令行形式,mysql基本命令的使用

1、命令的取消
\c

2、退出mysql窗口
exit;或quit;或ctrl+c

3、查看数据库版本号
select version();

4、显示当前存在的数据库
show databases;

5、选择test数据库
use test;

6、查看选择的数据库
select database();

7、设置数据库中文编码
set names utf8;

8、创建一个test数据库
create database test

9、创建一张mtest表
create table mtest(
id tinyint(2) unsigned not null auto_increment,
name varchar(20),
sex char(1),
email varchar(50),
birth datetime,
primary key (id)
);

10、向mtest表中插入一条数据
insert into mtest(`name`,`sex`,`email`,`birth`) values ('zhangsan','1','zhangsan@163.com',now());

11、查询mtest表中name为张三的信息
select * from mtest where name='zhangsan';

12、按照id号降序输出
select * from mtest order by id desc;

13、显示第11至20条数据信息
select * from mtest id limit 10,10;

 

一.首先配置jdk环境变量:

1.配置jdk的变量名,jdk的目录

 

2.配置jdk的path(路径\bin;)和mysql的path路径,指定bin目录(cmd下任意目录下可以访问mysql)

3.指定ClassPath

或者看以下配置:

1.环境变量的配置

我的电脑---属性-----高级------环境变量。

方法1 :固定配置:

A.

新建java_home: 找jdk目录。 例如新建 D:\Program Files\Java\jdk( 配置java_home以后就不怕换别的盘符了。直接修改java_home,不用修改path了)

B.

编辑path:       找bin路径。 在路径后面添加bin的路径 %java_home%\bin或者在没有配置java_home的情况下直接例如D:\Program Files\Java\jdk\bin(查找顺序,先在本目录查找,然后再在path路径查找。)

C.

CLASSpath 新建    确定找生成的.class目录。进入.java的目录后,如果在classpath中设置了.classpath的路径,就可以在dos环境下任意的目录下找到.class文件

二:

  1. C:\Windows\System32>mysql -hlocalhost -u用户名 -p密码 //输入 用户名和密码,登录数据库
  2. mysql> show databases;//查看数据库
  3. mysql> use 数据库名;//进入数据库
  4. mysql> show tables;//查看表
  5. mysql> desc 表;//查看表结构

 三.

创建数据库:
create database 数据库名;

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">create</span> <span style="COLOR: rgb(0,0,255)">database</span><span style="COLOR: rgb(0,0,0)"> sql_db;
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">use</span><span style="COLOR: rgb(0,0,0)"> sql_db;</span><span style="COLOR: rgb(128,128,128)"><br></span>

 

 
删除数据库:
drop database 数据库名;

在数据中(标准语句)
创建表:
create table 货物信息 (名称 类型 null|not null 主键或者唯一键,……);//包含了创建表时就建立约束语法。

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">create</span> <span style="COLOR: rgb(0,0,255)">table</span> student (id <span style="COLOR: rgb(0,0,255)">int</span> <span style="COLOR: rgb(128,128,128)">not</span> <span style="COLOR: rgb(0,0,255)">null</span> auto_increment <span style="COLOR: rgb(0,0,255)">primary</span> <span style="COLOR: rgb(0,0,255)">key</span>,name <span style="COLOR: rgb(0,0,255)">varchar</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">10</span>),cid <span style="COLOR: rgb(0,0,255)">int</span><span style="COLOR: rgb(0,0,0)">);
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">create</span> <span style="COLOR: rgb(0,0,255)">table</span> class (id <span style="COLOR: rgb(0,0,255)">int</span> <span style="COLOR: rgb(128,128,128)">not</span> <span style="COLOR: rgb(0,0,255)">null</span> auto_increment <span style="COLOR: rgb(0,0,255)">primary</span> <span style="COLOR: rgb(0,0,255)">key</span>,name <span style="COLOR: rgb(0,0,255)">varchar</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">10</span>));

删除表:
drop table 表名;

修改表 :
alter table 表名
增加列: add column 列名 数据类型(长度)null or not null 主键or唯一键;ADD [COLUMN] column_definition [FIRST | AFTER col_name ]

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">alter</span> <span style="COLOR: rgb(0,0,255)">table</span> student <span style="COLOR: rgb(0,0,255)">add</span> <span style="COLOR: rgb(0,0,255)">column</span> age  <span style="COLOR: rgb(0,0,255)">int</span> ;

删除列: drop column 列名;DROP [COLUMN] col_name

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">alter</span> <span style="COLOR: rgb(0,0,255)">table</span> student <span style="COLOR: rgb(0,0,255)">drop</span> <span style="COLOR: rgb(0,0,255)">column</span> age;

更改列: change column 原列名 新列名 数据类型(长度); CHANGE [COLUMN] old_col_name column_definition [FIRST|AFTER col_name]
               modify column 列名 数据类型(长度);MODIFY [COLUMN] column_definition [FIRST | AFTER col_name]

 

column_definition:
col_name data_type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY] [COMMENT 'string'] [reference_definition]

复制代码

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">desc</span><span style="COLOR: rgb(0,0,0)"> class;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-----+-------------+------+-----+---------+-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> Field <span style="COLOR: rgb(128,128,128)">|</span> Type        <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">Null</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">Key</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">Default</span> <span style="COLOR: rgb(128,128,128)">|</span> Extra <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-----+-------------+------+-----+---------+-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id    <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">int</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span>)     <span style="COLOR: rgb(128,128,128)">|</span> NO   <span style="COLOR: rgb(128,128,128)">|</span> PRI <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>       <span style="COLOR: rgb(128,128,128)">|</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span> name  <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">varchar</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">10</span>) <span style="COLOR: rgb(128,128,128)">|</span> YES  <span style="COLOR: rgb(128,128,128)">|</span>     <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>    <span style="COLOR: rgb(128,128,128)">|</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-----+-------------+------+-----+---------+-------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> rows <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)

如果想去除自动增长,则 先删除主键,再修改。
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">alter</span> <span style="COLOR: rgb(0,0,255)">table</span> class <span style="COLOR: rgb(0,0,255)">drop</span> <span style="COLOR: rgb(0,0,255)">primary</span> <span style="COLOR: rgb(0,0,255)">key</span><span style="COLOR: rgb(0,0,0)">;

mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">desc</span><span style="COLOR: rgb(0,0,0)"> class;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-----+-------------+------+-----+---------+-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> Field <span style="COLOR: rgb(128,128,128)">|</span> Type        <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">Null</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">Key</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">Default</span> <span style="COLOR: rgb(128,128,128)">|</span> Extra <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-----+-------------+------+-----+---------+-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id    <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">int</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span>)     <span style="COLOR: rgb(128,128,128)">|</span> NO   <span style="COLOR: rgb(128,128,128)">|</span>     <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>       <span style="COLOR: rgb(128,128,128)">|</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span> name  <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">varchar</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">10</span>) <span style="COLOR: rgb(128,128,128)">|</span> YES  <span style="COLOR: rgb(128,128,128)">|</span>     <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>    <span style="COLOR: rgb(128,128,128)">|</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-----+-------------+------+-----+---------+-------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> rows <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.01</span><span style="COLOR: rgb(0,0,0)"> sec)

mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">alter</span> <span style="COLOR: rgb(0,0,255)">table</span> class modify <span style="COLOR: rgb(0,0,255)">column</span> id <span style="COLOR: rgb(0,0,255)">int</span> <span style="COLOR: rgb(0,0,255)">null</span>;

复制代码

 

如果没有在原始没有给列添加为主键,可以 添加和删除约束的方法。
alter table 表名 add primary key(id);或者更改列 mysql> alter table 表 change id id int primary key;

例子:
mysql> alter table 表名 add primary key(id);

删除主键:
alter table 表名 drop primary key();

例子:
mysql> alter table emp drop primary key;

四.

表数据中的增删改查
1.向表中添加数据:(全部插入)insert into 表名 valus('','',……,'');
                               (部分插入)insert into 表名(列x,列y,……,列z) valus('','',……,''); 

复制代码

student中 (自动增长,赋予0和null 并不影响自动增长性。):
mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">insert</span> <span style="COLOR: rgb(0,0,255)">into</span> student <span style="COLOR: rgb(0,0,255)">values</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>,<span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">s1</span><span style="COLOR: rgb(255,0,0)">'</span>,<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span><span style="COLOR: rgb(0,0,0)">);
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">insert</span> <span style="COLOR: rgb(0,0,255)">into</span> student <span style="COLOR: rgb(0,0,255)">values</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>,<span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">s2</span><span style="COLOR: rgb(255,0,0)">'</span>,<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span><span style="COLOR: rgb(0,0,0)">);
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">insert</span> <span style="COLOR: rgb(0,0,255)">into</span> student <span style="COLOR: rgb(0,0,255)">values</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>,<span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">s3</span><span style="COLOR: rgb(255,0,0)">'</span>,<span style="COLOR: rgb(0,0,255)">null</span><span style="COLOR: rgb(0,0,0)">);<br><span style="COLOR: rgb(255,255,255); BACKGROUND-COLOR: rgb(128,0,0)">mysql> insert into student values(0,'s3',3);//将在2中被删除</span>
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">insert</span> <span style="COLOR: rgb(0,0,255)">into</span> student <span style="COLOR: rgb(0,0,255)">values</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>,<span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">s4</span><span style="COLOR: rgb(255,0,0)">'</span>,<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span><span style="COLOR: rgb(0,0,0)">);
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">insert</span> <span style="COLOR: rgb(0,0,255)">into</span> student(id,name) <span style="COLOR: rgb(0,0,255)">values</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>,<span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">s5</span><span style="COLOR: rgb(255,0,0)">'</span>);<br><br>
class中:

复制代码

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">insert</span> <span style="COLOR: rgb(0,0,255)">into</span> class(id,name) <span style="COLOR: rgb(0,0,255)">values</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span>,<span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">c1</span><span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(0,0,0)">);
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">insert</span> <span style="COLOR: rgb(0,0,255)">into</span> class(id,name) <span style="COLOR: rgb(0,0,255)">values</span>(<span style="COLOR: rgb(0,0,255)">null</span>,<span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">c2</span><span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(0,0,0)">); 
//指定id为4
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">insert</span> <span style="COLOR: rgb(0,0,255)">into</span> class(id,name) <span style="COLOR: rgb(0,0,255)">values</span>(2,<span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">c3</span><span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(0,0,0)">);


mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span><span style="COLOR: rgb(0,0,0)"> class;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> c1   <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> c2   <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">4</span> <span style="COLOR: rgb(128,128,128)">|</span> c3   <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+</span>

复制代码

复制代码

 

2.向表中删除行数据:delect from 表名;(清空表)
                                  delect from 表名 where [检索条件表达式]

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">delete</span> <span style="COLOR: rgb(0,0,255)">from</span> student <span style="COLOR: rgb(0,0,255)">where</span> id<span style="COLOR: rgb(128,128,128)">=</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">4</span>;

 

3.更改表中的数据:update 表名 set 列名='表达式' [from 另一表名] where [检索条件表达式];

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">update</span> student <span style="COLOR: rgb(0,0,255)">set</span> name<span style="COLOR: rgb(128,128,128)">=</span><span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">s11</span><span style="COLOR: rgb(255,0,0)">'</span> <span style="COLOR: rgb(0,0,255)">where</span> id<span style="COLOR: rgb(128,128,128)">=</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span>;

 

4.查询表中的数据:select          */表字段1,表字段2,……表字段n     from 表名 【where 查询条件】;

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span><span style="COLOR: rgb(0,0,0)"> student;
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span> student <span style="COLOR: rgb(0,0,255)">where</span> id<span style="COLOR: rgb(128,128,128)">=</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span><span style="COLOR: rgb(0,0,0)">;
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> id,name <span style="COLOR: rgb(0,0,255)">from</span><span style="COLOR: rgb(0,0,0)"> student;
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> id,name <span style="COLOR: rgb(0,0,255)">from</span> student <span style="COLOR: rgb(0,0,255)">where</span> id <span style="COLOR: rgb(128,128,128)">in</span>(<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span>,<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3,4</span>);<span style="COLOR: rgb(128,128,128)">//</span>in表示集合。

 

特殊查询:

复制代码

//增加一列<br>mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">alter</span> <span style="COLOR: rgb(0,0,255)">table</span> student <span style="COLOR: rgb(0,0,255)">add</span> <span style="COLOR: rgb(0,0,255)">column</span> createDate date;
//查询是否增加<br>mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span><span style="COLOR: rgb(0,0,0)"> student;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> s11  <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> s2   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> s3   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> <span style="COLOR: rgb(128,128,128)">|</span> s4   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">6</span> <span style="COLOR: rgb(128,128,128)">|</span> s5   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> rows <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)
<br>//插入date类型格式的日期。
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">update</span> student <span style="COLOR: rgb(0,0,255)">set</span> createDate<span style="COLOR: rgb(128,128,128)">=</span><span style="COLOR: rgb(255,0,0)">'</span><span style="COLOR: rgb(255,0,0)">2012-11-16</span><span style="COLOR: rgb(255,0,0)">'</span> <span style="COLOR: rgb(0,0,255)">where</span> id<span style="COLOR: rgb(128,128,128)">=</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span><span style="COLOR: rgb(0,0,0)">;//date时间类型 yyyy-mm-dd 格式  。createDate='2012-9-8',必须这么写。
Query OK, </span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> row affected (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.02</span><span style="COLOR: rgb(0,0,0)"> sec)
Rows matched: </span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span>  Changed: <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span>  Warnings: <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span><span style="COLOR: rgb(0,0,0)">
<br>
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span><span style="COLOR: rgb(0,0,0)"> student;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> s11  <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> s2   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> s3   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">16</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> <span style="COLOR: rgb(128,128,128)">|</span> s4   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">6</span> <span style="COLOR: rgb(128,128,128)">|</span> s5   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> rows <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)
<br>//插入当前日期</span><span style="COLOR: rgb(0,0,0)">
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">update</span> student <span style="COLOR: rgb(0,0,255)">set</span> createDate<span style="COLOR: rgb(128,128,128)">=</span>now() <span style="COLOR: rgb(0,0,255)">where</span> id<span style="COLOR: rgb(128,128,128)">=</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span><span style="COLOR: rgb(0,0,0)">;
Query OK, </span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> row affected (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)
Rows matched: </span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span>  Changed: <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span>  Warnings: <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span><span style="COLOR: rgb(0,0,0)">

mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span><span style="COLOR: rgb(0,0,0)"> student;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> s11  <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> s2   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> s3   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">16</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> <span style="COLOR: rgb(128,128,128)">|</span> s4   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">17</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">6</span> <span style="COLOR: rgb(128,128,128)">|</span> s5   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> rows <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)
<br><br>统计查询(sum.avg,count)</span>

复制代码

<br>mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(255,0,255)">count</span>(<span style="COLOR: rgb(128,128,128)">*</span>) <span style="COLOR: rgb(0,0,255)">from</span> student <span style="COLOR: rgb(0,0,255)">where</span> id<span style="COLOR: rgb(128,128,128)">></span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span><span style="COLOR: rgb(0,0,0)">;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(255,0,255)">count</span>(<span style="COLOR: rgb(128,128,128)">*</span>) <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>        <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> row <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.03</span><span style="COLOR: rgb(0,0,0)"> sec)

mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(255,0,255)">count</span>(name) <span style="COLOR: rgb(0,0,255)">from</span> student <span style="COLOR: rgb(0,0,255)">where</span> id<span style="COLOR: rgb(128,128,128)">></span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span><span style="COLOR: rgb(0,0,0)">;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-----------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(255,0,255)">count</span>(name) <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-----------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>           <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-----------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> row <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)

mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(255,0,255)">sum</span>(id) <span style="COLOR: rgb(0,0,255)">from</span><span style="COLOR: rgb(0,0,0)"> student;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(255,0,255)">sum</span>(id) <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>      <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">17</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> row <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.03</span> sec)<br><br>

复制代码

<span style="COLOR: rgb(0,0,0)">查询最大的id
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(255,0,255)">max</span>(id) <span style="COLOR: rgb(0,0,255)">from</span><span style="COLOR: rgb(0,0,0)"> student;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(255,0,255)">max</span>(id) <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>       <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">6</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> row <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)

查询最小的id
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(255,0,255)">min</span>(id) <span style="COLOR: rgb(0,0,255)">from</span><span style="COLOR: rgb(0,0,0)"> student;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(255,0,255)">min</span>(id) <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>       <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">-------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> row <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.07</span> sec)

复制代码

复制代码

 

复制代码

分页查询(mysql专用):

page表示要查询的页码(1开始),pagesize表示一页显示多少条记录
begin=(page-1)*pagesize;表示查询页开始的行号。 注意:行记录是从0开始

<br>mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span> 表 limit <span style="COLOR: rgb(0,0,255)">begin</span><span style="COLOR: rgb(0,0,0)">,pagesize;

mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span> student limit <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>,<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span><span style="COLOR: rgb(0,0,0)">;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> s11  <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> s2   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> s3   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">16</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> rows <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.03</span><span style="COLOR: rgb(0,0,0)"> sec)


mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span> student limit <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span>,<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span><span style="COLOR: rgb(0,0,0)">;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> <span style="COLOR: rgb(128,128,128)">|</span> s4   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">17</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">6</span> <span style="COLOR: rgb(128,128,128)">|</span> s5   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>

复制代码

复制代码

查询 id<span style="COLOR: rgb(128,128,128)"><span style="COLOR: rgb(0,0,0)">3的,再以分页显示
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span> student <span style="COLOR: rgb(0,0,255)">where</span> id<span style="COLOR: rgb(128,128,128)"><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> limit <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>,<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span><span style="COLOR: rgb(0,0,0)">;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> s11  <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> row <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)

</span><span style="COLOR: rgb(128,128,128)">//</span><span style="COLOR: rgb(0,0,0)">降序
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span> student <span style="COLOR: rgb(0,0,255)">order</span> <span style="COLOR: rgb(0,0,255)">by</span> id <span style="COLOR: rgb(0,0,255)">desc</span><span style="COLOR: rgb(0,0,0)">;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">6</span> <span style="COLOR: rgb(128,128,128)">|</span> s5   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> <span style="COLOR: rgb(128,128,128)">|</span> s4   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">17</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> s3   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">16</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> s2   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> s11  <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> rows <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)

升序(默认)
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span> student <span style="COLOR: rgb(0,0,255)">order</span> <span style="COLOR: rgb(0,0,255)">by</span> id <span style="COLOR: rgb(0,0,255)">asc</span><span style="COLOR: rgb(0,0,0)">;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> s11  <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> s2   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> s3   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">16</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> <span style="COLOR: rgb(128,128,128)">|</span> s4   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">17</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">6</span> <span style="COLOR: rgb(128,128,128)">|</span> s5   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> rows <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span><span style="COLOR: rgb(0,0,0)"> sec)

查询id</span><span style="COLOR: rgb(128,128,128)">></span><span style="COLOR: rgb(0,0,0)">2的,降序排列,分页查询
mysql</span><span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span> student <span style="COLOR: rgb(0,0,255)">where</span> id <span style="COLOR: rgb(128,128,128)">></span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> <span style="COLOR: rgb(0,0,255)">order</span> <span style="COLOR: rgb(0,0,255)">by</span> id <span style="COLOR: rgb(0,0,255)">desc</span>  limit <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0</span>,<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span><span style="COLOR: rgb(0,0,0)">;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">6</span> <span style="COLOR: rgb(128,128,128)">|</span> s5   <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">5</span> <span style="COLOR: rgb(128,128,128)">|</span> s4   <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">3</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2012</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">11</span><span style="COLOR: rgb(128,128,128)">-</span><span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">17</span> <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+</span>
<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">2</span> rows <span style="COLOR: rgb(128,128,128)">in</span> <span style="COLOR: rgb(0,0,255)">set</span> (<span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">0.00</span> sec)</span></span>

复制代码

复制代码

链接查询(针对2个表):

3.关联查询:
mysql> select * from 表1,表2 where 表1.列1=表2.列2 

复制代码

mysql<span style="COLOR: rgb(128,128,128)">></span> <span style="COLOR: rgb(0,0,255)">select</span> <span style="COLOR: rgb(128,128,128)">*</span> <span style="COLOR: rgb(0,0,255)">from</span> student s,class c <span style="COLOR: rgb(0,0,255)">where</span> s.cid<span style="COLOR: rgb(128,128,128)">=</span><span style="COLOR: rgb(0,0,0)">c.id;
</span><span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+------+------+</span>
<span style="COLOR: rgb(128,128,128)">|</span> id <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span> cid  <span style="COLOR: rgb(128,128,128)">|</span> createDate <span style="COLOR: rgb(128,128,128)">|</span> id   <span style="COLOR: rgb(128,128,128)">|</span> name <span style="COLOR: rgb(128,128,128)">|</span>
<span style="COLOR: rgb(128,128,128)">+</span><span style="COLOR: rgb(0,128,128)">--</span><span style="COLOR: rgb(0,128,128)">--+------+------+------------+------+------+</span>
<span style="COLOR: rgb(128,128,128)">|</span>  <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> s11  <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> <span style="COLOR: rgb(0,0,255)">NULL</span>       <span style="COLOR: rgb(128,128,128)">|</span>    <span style="FONT-WEIGHT: bold; COLOR: rgb(128,0,0)">1</span> <span style="COLOR: rgb(128,128,128)">|</span> c1   <span style="COLOR"></span>
성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
MySQL에서 사용 가능한 다른 스토리지 엔진은 무엇입니까?MySQL에서 사용 가능한 다른 스토리지 엔진은 무엇입니까?Apr 26, 2025 am 12:27 AM

mysqloffersvariousStorageEngines, 각각의 everitedforentUsecases : 1) innodbisidealforapplicationsneedingAcidCoInceandHighConcurrency, 지원 트랜잭션 및 foreignKeys.2) myIsAmisbestforread-heverworkloads, memoryengineis

MySQL의 일반적인 보안 취약점은 무엇입니까?MySQL의 일반적인 보안 취약점은 무엇입니까?Apr 26, 2025 am 12:27 AM

MySQL의 일반적인 보안 취약점에는 SQL 주입, 약한 암호, 부적절한 권한 구성 및 업데이트되지 않은 소프트웨어가 포함됩니다. 1. 전처리 명령문을 사용하여 SQL 주입을 방지 할 수 있습니다. 2. 강력한 비밀번호 전략을 사용하여 약한 암호는 피할 수 있습니다. 3. 정기적 인 검토 및 사용자 권한 조정을 통해 부적절한 권한 구성을 해결할 수 있습니다. 4. Unupdated 소프트웨어는 MySQL 버전을 정기적으로 확인하고 업데이트하여 패치 할 수 있습니다.

MySQL에서 느린 쿼리를 어떻게 식별 할 수 있습니까?MySQL에서 느린 쿼리를 어떻게 식별 할 수 있습니까?Apr 26, 2025 am 12:15 AM

느린 쿼리 로그를 활성화하고 임계 값을 설정하여 MySQL에서 느린 쿼리를 식별 할 수 있습니다. 1. 느린 쿼리 로그를 활성화하고 임계 값을 설정하십시오. 2. 느린 쿼리 로그 파일을보고 분석하고 심층 분석을 위해 MySQLDumpSlow 또는 PT-Query 소수성과 같은 도구를 사용하십시오. 3. 인덱스 최적화, 쿼리 재 작성 및 select*의 사용을 피함으로써 느린 쿼리 최적화를 달성 할 수 있습니다.

MySQL 서버 건강 및 성능을 어떻게 모니터링 할 수 있습니까?MySQL 서버 건강 및 성능을 어떻게 모니터링 할 수 있습니까?Apr 26, 2025 am 12:15 AM

MySQL 서버의 건강 및 성능을 모니터링하려면 시스템 건강, 성능 지표 및 쿼리 실행에주의를 기울여야합니다. 1) 시스템 건강 모니터링 : CPU, 메모리, 디스크 I/O 및 네트워크 활동을 볼 수 있도록 상단, HTOP 또는 ShowGlobalStatus 명령을 사용하십시오. 2) 성능 표시기 추적 : 초당 쿼리 번호, 평균 쿼리 시간 및 캐시 적중률과 같은 주요 표시기를 모니터링합니다. 3) 쿼리 실행 최적화 확인 : 실행 시간이 설정 임계 값을 초과하는 쿼리를 느린 쿼리 로그를 활성화하고 기록 및 최적화하십시오.

MySQL 및 Mariadb를 비교하고 대조하십시오.MySQL 및 Mariadb를 비교하고 대조하십시오.Apr 26, 2025 am 12:08 AM

MySQL과 Mariadb의 주요 차이점은 성능, 기능 및 라이센스입니다. 1. MySQL은 Oracle에 의해 개발되었으며 Mariadb는 포크입니다. 2. MariaDB는 높은 하중 환경에서 더 나은 성능을 발휘할 수 있습니다. 3. Mariadb는 더 많은 스토리지 엔진과 기능을 제공합니다. 4.MySQL은 듀얼 라이센스를 채택하고 MariaDB는 완전히 오픈 소스입니다. 선택할 때 기존 인프라, 성능 요구 사항, 기능 요구 사항 및 라이센스 비용을 고려해야합니다.

MySQL의 라이센스는 다른 데이터베이스 시스템과 어떻게 비교됩니까?MySQL의 라이센스는 다른 데이터베이스 시스템과 어떻게 비교됩니까?Apr 25, 2025 am 12:26 AM

MySQL은 GPL 라이센스를 사용합니다. 1) GPL 라이센스는 MySQL의 무료 사용, 수정 및 분포를 허용하지만 수정 된 분포는 GPL을 준수해야합니다. 2) 상업용 라이센스는 공개 수정을 피할 수 있으며 기밀이 필요한 상업용 응용 프로그램에 적합합니다.

MyISAM을 통해 언제 innodb를 선택 하시겠습니까?MyISAM을 통해 언제 innodb를 선택 하시겠습니까?Apr 25, 2025 am 12:22 AM

MyISAM 대신 InnoDB를 선택할 때의 상황에는 다음이 포함됩니다. 1) 거래 지원, 2) 높은 동시성 환경, 3) 높은 데이터 일관성; 반대로, MyISAM을 선택할 때의 상황에는 다음이 포함됩니다. 1) 주로 읽기 작업, 2) 거래 지원이 필요하지 않습니다. InnoDB는 전자 상거래 플랫폼과 같은 높은 데이터 일관성 및 트랜잭션 처리가 필요한 응용 프로그램에 적합하지만 MyISAM은 블로그 시스템과 같은 읽기 집약적 및 트랜잭션이없는 애플리케이션에 적합합니다.

MySQL에서 외국 키의 목적을 설명하십시오.MySQL에서 외국 키의 목적을 설명하십시오.Apr 25, 2025 am 12:17 AM

MySQL에서 외국 키의 기능은 테이블 간의 관계를 설정하고 데이터의 일관성과 무결성을 보장하는 것입니다. 외국 키는 참조 무결성 검사 및 계단식 작업을 통해 데이터의 효과를 유지합니다. 성능 최적화에주의를 기울이고 사용할 때 일반적인 오류를 피하십시오.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

MinGW - Windows용 미니멀리스트 GNU

MinGW - Windows용 미니멀리스트 GNU

이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

VSCode Windows 64비트 다운로드

VSCode Windows 64비트 다운로드

Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 Linux 새 버전

SublimeText3 Linux 새 버전

SublimeText3 Linux 최신 버전

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는