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

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 sumvalue from table1
平均:select avg(field1) as avgvalue from table1
最大:select max(field1) as maxvalue from table1
最小:select min(fi


相关文档:

sql Server2000 数据库邮件

*
提供两种版本的OutLook邮件发送方式
有疑问联系作者: zlp321001@hotmail.com
*/
A:利用OutLook2003发送邮件
----------------------------------------------------------------------
/
*测试环境: windowx Xp
 OutLook: OutLook 2003
 测试的电子邮件: zlp321001@126.com
/
第一步骤:建配置文件 ......

sql查询的无限分类查询的设计

最近在找一次sql查询的无限分类查询的设计,网上找了一下这个数据表的设计很有特色,
不用递归,依靠个简单SQL语句就能列出菜单,看看这个数据表怎么设计的,并对下面的数据表结构的查询进行分析.
数据库字段大概如下:
-----------------------------------------------------------------------------------
id  ......

SQL-查询所有触发器

----查看所有角本
Create table #y (txt text)
select name, iid = identity(int,1,1) into #x from SysObjects where xtype = 'TR'
declare @i int, @max int
declare @name varchar(40)
set @i = 1
select @max = max(iid) from #x
while @i <= @max
begin
    select @name = name from #x w ......

sql c#

C-#入门经典(第三版).pdf
using System;
using System.Data;
using System.Data.SqlClient;
namespace My_Student
{
    static class Program
    {
       
        static void Main()
  &n ......

SQL Server中关于的checkpoint使用说明

在SQL Server中有一个非常重要的命令就是CheckPoint,它主要作用是把缓存中的数据写入mdf文件中。
其实在我们进行insert, update, delete时,数据并没有直接写入数据库对应的mdf文件中,而是写入了缓存里,这有点像电驴,因为过于频繁的写入会使磁盘的寿命大大减小。
 
从上图可以直观的看出。只有当发生checkpoint ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号