常用sql相关
1修改基本表
添加列 alter table tableName add<新列名><数据类型>[完整性约束]
删除列 alter table tableName drop<新列名><数据类型>[完整性约束]
2创建
建表create table tableName(
id primary key AUTO_INCREMENT(mysql);
id primary key identity(1,1)(sql server)
)
建立索引
create index OID_IDX on 表名(number);
create unique index oin_idx on 表名(number);创建唯一索引
3 删除
删除索引 drop index <索引名>
删除表 drop table <表名>
4 sql功能
数据查询 select
数据定义 create drop alter
数据操控 insert update delete
数据控制 grant(授权) revoke(收回权限)
(1) 数据查询
select * from tableName where <条件表达式> group by<列名>[having<条件>] order by<列名>[ASC DESC]
select distinct Sno from sc 查询数据去掉重复行
常见的查询条件
比较 = ,>,<,<=,<=,!=,<>,!<,!>,
确定范围 between and |not between and
确定集合 in ,not in
字符匹配 like ,not like like '<匹配符>' 匹配符可以包含通配符%和_
空值 is null ,is not null
多重条件(逻辑运算) and,or,not
select a.name,a.mialbox from a where EXISTS(select b.name from b where a.name=b.name)
联接查询join
select a.number,a,name,b.age,b.sort from a join b on a.number=b.number
inner join 内联接 用于返回两个表中要查询的列数据 left join right join
常见运算以及聚集函数
ABS(x)返回绝对值
&
相关文档:
例子: int id = Convert.ToInt32(replace((Request.QueryString["id"]), ""));
public static string replace(string str, string str2)
{
str = str.Replace(";", str2);
str = ......
在sql中创建用户自定义拼音函数:
create function f_GetPy(@Str nvarchar(400))
returns nvarchar(4000)
as
begin
declare @strlen int,@re nvarchar(4000)
declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1))
insert @t select '吖','A' union all select '八','B'
union all select '嚓 ......
Sql Server 查询sql执行各个阶段的时间
set statistics io on
set statistics time on
set statistics profile on
go
[你的sql语句]
go
set statistics io off
set statistics time off
set statistics profile off
我运行:
set statistics io on
set statistics time on
set statistics profile on ......
1.直接导入数据库
shp2pgsql -s "4326" -W "GBK" E:\shape\Road_polyline.shp
road_cross| psql -U postgres -h 172.17.40.83 -d test
2.导出sql
shp2pgsql -s "4326" E:\shape\Road_polyline.shp blocks >
E:\roadcross\blocks.sql
3 ......
转载:http://blog.csdn.net/cnming/archive/2009/03/11/3979290.aspx
在查询分析器中顺序执行以下三步,其中 databasename 为你的数据库文件名
1.清空日志:DUMP TRANSACTION databasename WITH NO_LOG
2.截断事务日志:BACKUP ......