易截截图软件、单文件、免安装、纯绿色、仅160KB

经典sql语句

 经典SQL语句大全
下列语句部分是Mssql语句,不可以在access中使用。
  SQL分类:
  DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE)
  DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT)
  DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK)
  首先,简要介绍基础语句:
  1、说明:创建数据库
CREATE DATABASE database-name
  2、说明:删除数据库
drop database dbname
  3、说明:备份sql server
  --- 创建 备份数据的 device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
  --- 开始 备份
BACKUP DATABASE pubs TO testBack
  4、说明:创建新表
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
  根据已有的表创建新表:
A:create table tab_new like tab_old (使用旧表创建新表)
B:create table tab_new as select col1,col2… from tab_old definition only
  5、说明:
  删除新表:drop table tabname
  6、说明:
  增加一个列:Alter table tabname add column col type
  注:列增加后将不能删除。DB2中列加上后数据类型也不能改变,唯一能改变的是增加varchar类型的长度。
  7、说明:
  添加主键:Alter table tabname add primary key(col)
  说明:
  删除主键:Alter table tabname drop primary key(col)
  8、说明:
  创建索引:create [unique] index idxname on tabname(col….)
  删除索引:drop index idxname
  注:索引是不可更改的,想更改必须删除重新建。
  9、说明:
  创建视图:create view viewname as select statement
  删除视图:drop view viewname
10、说明:几个简单的基本的sql语句
  选择:select * from table1 where 范围
  插入:insert into table1(field1,field2) values(value1,value2)
  删除:delete from table1 where 范围
  更新:update table1 set field1=value1 where 范围
  查找:select * from table1 where field1 like ’%value1%’ ---like的语法很精妙,查资料!
  排序:select * from table1 order by field1,field2 [desc]
  总数:select count * as totalcount from table1
  求和:select sum(field1) as su


相关文档:

整理比较全的Access SQL注入参考

 Access SQL注入参考
版本 0.2.1
(最近更新 10/10/2007)
原作者不详
 
描述 SQL查询及注释
注释符 Access中没有专门的注释符号.因此"/*", "--"和"#"都没法使用.但是可以使用空字符"NULL"(%00)代替:
' UNION SELECT 1,1,1 from validTableName%00
 
语法错误信息 "[Microsoft][Driver ODBC Micros ......

Delphi Excel to Sql Server

 unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB,comobj, OleServer,
  ExcelXP;
type
  TForm1 = class(TForm)
    ADOConn: TADOConnection;
& ......

获取SQL Server服务器列表的几种方法

一、 SQL DMO 描述:SQL Distributed Management Objects(SQL分布式管理对象),存在于SQLDMO.dll文件中,实际上是一个COM 对象,通过调用SQL DMO的ListAvailableSQLServers方法取得。 列表类型:列举装有“客户端”和“服务端”的计算机。 适用条件:装有 SQL Server,且有SQLDMO.dll文件。 速度:中 调用示例:GetS ......

Image To SQL Server

/*
use master
go
if DB_ID('UserImage') is not null
   drop database UserImage
create database UserImage
go
use UserImage
go
create table Images
(
 Image_Name nvarchar(255) primary key,
 Image_Data Image not null
)
go
create proc InsertImage
(
 @Image_Name nv ......

SQL语句优化

 SQL语句优化:
(1)可以过滤掉最大数量记录的条件必须写在WHERE子句的末尾.
(2)SELECT子句中避免使用 ‘ * ‘
(3)减少访问数据库的次数
方法3 (高效)?
SELECT A.EMP_NAME , A.SALARY , A.GRADE,
B.EMP_NAME , B.SALARY , B.GRADE
from EMP A,EMP B
WHERE A.EMP_NO = 342
AND B.EMP_NO = 291;
( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号