1.create database; 数据库名 //创建一个数据库
2.show databases; //查看当前有哪些数据库
3.use 数据库名; //选择一个数据库进行操作
4.show tables; //查看当前有哪些表
5.desc 表名; //查看表结构
6.select * from 表名; //查看插入数据内容
7.drop table 表名; //删除表
8.drop database 数据库名 //删除数据库
9. create table 表名(名1 int,名2 varchar(20),名3 varchar(20),名4 int,名5 date)default charset=utf8;
10. insert into 表名(名1,名2,名3,名4,名5)values(1,"小米","男",99,now());
//update 修改
11, update 表名 set 字段名='新的内容' where id=1; //修改插入数据内容
@ alter table 表名 change 原名 新名 列类型; //修改列名
列:alter table a change d yyc varchar(20);
12. alter table 表名 add 子段名 类型 修饰 ; //修改数据表
// alter table yy add aa int(8); //添加列
13. alter table 表名 drop 列名称 //删除列
//alter table yy drop aa;
14. @ select * from yy where 名1=2; //单独查询其中一行信息 *:代表所有列
@ select fname,字段名1,字段名2 from 表; //查询其中一列的信息
@ select * from 表名 where 字段名 like "数值开头%"; //模糊查询
//聚合函数
@ select count(*) from 表名; //总数
//查询出当前表中的行数 count() 中也可以放字段
@ select max(id) from 表名; //最大值
//查询当前表中的id列最大的一个id
@ select min(id) from 表名; //最小值
//查询当前表中的id列最小的一个id
@ select avg(id) from 表名; //平均数
//查询当前表中的数据id总和的平均数
@ select sum(id) from 表名; //总合
//查询当前表中的数据id总合
@ 把id类型的数字排序
@ select 字段名id from 表名 order by 字段名id asc; //otder by 排序 ase:正排序
@ select 字段名id from 表名 order by 字段名id desc; //otder by 排序 desc:倒排序
]
15. delete from 表名 where 条件; //删除插入数据其中的一条内容
//delete from yy where 名1=2;
@ alter table m add primary key (a);//把原有的表添加主健
@ alter table qq modify a integer auto_increment; //把原有的表添加主健自增
@ alter table qq modify a int; //删除主健自增
@ alter table qq drop primary key; //删除主健
//添加主健自增首先要添加主健;
//删除主健首先要删除主健自增;
@alter table ff modify title varchar(20);//把非空变为空
16. //主见(名1)不被重复
方法一, create table www(名1 int primary key,名2 varchar(20),名3 varchar(20),名4 int,名5 date)default charset=utf8;
方法二, create table ww(名1 int,名2 varchar(20),名3 varchar(20),名4 int,名5 date,primary key(`名1`))default charset=utf8; (`名1`)单引号必须是波浪线单引号
(`名1`)单引号不加也可以(名1)
17. create table if not exists qqqq(名1 int,名2 varchar(20),名3 varchar(20),名4 int,名5 date,primary key(名1))default charset=utf8;
//if not esists /表示如果有相同名字的话,会显示警告,不能创建!!
/如没有相同名字则直接创建
18. create table www(名1 int primary key auto_increment,名2 varchar(20),名3 varchar(20),名4 int,名5 date)default charset=utf8;
insert into oo(名2,名3,名4,名5)values("小米","男",99,now());
//自身名1(id)加1;
//自增只能用于数字类型
insert into o(名1,名2,名3,名4,名5)values(2,"小米","男",99,now());
//从2开始
21. create table ff(id int primary key auto_increment,title varchar(20) not null,author varchar(20) not null,date date)default charset=utf8;
title varchar(20) // 后面加 not null
//让字段名不为空
insert into //插入 写入
values //数值
where //
alter //改变
change //改变,变换
person order
modify integer //修改整数
not null
alter table table-name drop col-name;
增加列(单列)
alter table table-name add col-name col-type comment 'xxx';
增加列(多列)
alter table table-name add col-name col-type comment 'xxx', add col-name col-type(col-length) comment 'xxx';
增加表字段并指明字段放置为第一列
alter table table-name add col-name col-type COMMENT 'sss' FIRST;
增加表字段并指明字段放置为特定列后面
alter table table-name add col-name col-type after col-name-1;
使用MODIFY修改字段类型
alter table table-name modify column col-name col-type;
使用CHANGE修改字段类型
alter table table-name change col-name col-name col-type;
使用CHANGE修改字段名称
alter table table-name change old-col-name new-col-name col-type;
修改列类型、长度
alter table table-name change old-col-name new-col-name new-col-type;
查看表中列属性
show columns from table-name;
修改表名
rename table old-table-name to new-table-name;
为字段设置NULL和DEFAULT
alter table table-name modify col-name col-type not null default 100;
修改字段的默认值
alter table table-name alter col-name set default 10000;
字段删除默认值
alter table table-name alter col-name drop default;
APS.NET MVC + EF (00)---C#基础
Asp.net MVC 之ActionResult
在ASP.NET MVC中加载部分视图的方法及差别
Entity Framework Codefirst数据迁移
Entity Framework Codefirst的配置步骤
02:PostgreSQL Character Sets
安装postgis,使用postgis导入shapefile的步骤总结
WebGIS实现在线要素编辑之ArcGIS Server 发布Feature Service 过程解析
DEM数据及其他数据下载