SQL语句基本操作
2014-05-20 15:40
253 查看
数据库工具 sql yog(中文版) Navicat Premium(英文版)
mysql数据库-->Database(数据库)-->table(数库表)-->field(字段)
增加---insert into table(字段名)values(值);
删除---delete from table where id='字段名';
修改---update table set name='字段名' where id=1;
查询---select */整张表 from table/表名 select id=1/单个查询, name/字段
名 from table/表名;
删除数据库---drop database;
show database;//查询所有数据库
create database studnt;//创建数据库
use student;//使用数据库
create table stu(id int not null primary key AUTO_INCREMENT,name
varchar(50))
age varchar(100);//创建表
insert into stu(id,name,age)values(1,'长沙源码','10');//增加
select * from stu;//查询全部
insert into stu(id,name,age) values(2,'中南大学','90'),(3,'湖南大
学','100');增加
select * from stu;//查询全部
select count(*) from table;//查询数据条数
select max(id) from stu;//查询最大值 (只能是int型)
select min(id) from stu;//查询最小值 (只能是int型)
select * from stu where id=(select max(id) from stu);//子查询
select * from stu order by id desc;//降序
select * from stu order by(排序) id asc;//升序
select * from stu limit 0,2;//如果是从0开始 取小于2
select * from stu limit 1,2;//从1开始 取2条
select * from stu where stuaddress like '% %'//模糊查询
charset=uf8;//更改编码
select sum(id) as (id号) from table;//查询总和
select * from table group by id;//分组
drop table id//删除表格
having与where类似,可筛选
where ->group by ->having->order ->limit 先后顺序
where 条件查询
group by 分组
having 筛选
order by 排序
limit 限制条数
in //去掉指定条数 between //去多少之多少之间
文章,新闻等安全性要求不高的 选myisam
订单,资金,涉及金额的 选innodb
alter table add primary key //增加主键索引
alter table add unique //增加唯一索引
alter table drop primary key // 删除主键索引
alter table drop index 索引名
mysql数据库-->Database(数据库)-->table(数库表)-->field(字段)
增加---insert into table(字段名)values(值);
删除---delete from table where id='字段名';
修改---update table set name='字段名' where id=1;
查询---select */整张表 from table/表名 select id=1/单个查询, name/字段
名 from table/表名;
删除数据库---drop database;
show database;//查询所有数据库
create database studnt;//创建数据库
use student;//使用数据库
create table stu(id int not null primary key AUTO_INCREMENT,name
varchar(50))
age varchar(100);//创建表
insert into stu(id,name,age)values(1,'长沙源码','10');//增加
select * from stu;//查询全部
insert into stu(id,name,age) values(2,'中南大学','90'),(3,'湖南大
学','100');增加
select * from stu;//查询全部
select count(*) from table;//查询数据条数
select max(id) from stu;//查询最大值 (只能是int型)
select min(id) from stu;//查询最小值 (只能是int型)
select * from stu where id=(select max(id) from stu);//子查询
select * from stu order by id desc;//降序
select * from stu order by(排序) id asc;//升序
select * from stu limit 0,2;//如果是从0开始 取小于2
select * from stu limit 1,2;//从1开始 取2条
select * from stu where stuaddress like '% %'//模糊查询
charset=uf8;//更改编码
select sum(id) as (id号) from table;//查询总和
select * from table group by id;//分组
drop table id//删除表格
having与where类似,可筛选
where ->group by ->having->order ->limit 先后顺序
where 条件查询
group by 分组
having 筛选
order by 排序
limit 限制条数
in //去掉指定条数 between //去多少之多少之间
文章,新闻等安全性要求不高的 选myisam
订单,资金,涉及金额的 选innodb
alter table add primary key //增加主键索引
alter table add unique //增加唯一索引
alter table drop primary key // 删除主键索引
alter table drop index 索引名
相关文章推荐
- 掌握SQL四条最基本的数据操作语句:Insert,Select,Update和Delete
- 基本的sql语句操作
- 用SQL语句添加删除修改字段、一些表与字段的基本操作、数据库备份等
- 利用SQL语句进行添加、删除、修改字段,表与字段的基本操作,数据库备份等
- sql 基本操作语句
- 掌握sql四条最基本的数据操作语句
- SQL语句添加、修改、删除字段及一些表与字段的基本操作
- 用SQL语句添加删除修改字段、一些表与字段的基本操作、数据库备份等
- MS SQL 2005基本操作(一):SQL语句对表、视图、索引和同义词的操作
- 基本SQL操作语句
- SQL基本操作语句全集
- 掌握SQL四条最基本的数据操作语句:Insert,Select,Update和Delete
- 用SQL语句添加删除修改字段及一些表与字段的基本操作 .
- SQL语句的基本操作
- Sql Server实用操作-动态sql语句基本语法
- 数据库操作基本SQL语句
- 用SQL语句添加删除修改字段、一些表与字段的基本操作、数据库备份等
- SQL基本操作语句全集
- 用SQL语句添加删除修改字段、一些表与字段的基本操作、数据库备份等
- sql 基本操作语句