SQLÓï¾ä´´½¨£¨Êý¾Ý¿â|Êý¾Ý±í|Ë÷Òý£©
CREATE Table <±íÃû>
£¨[<ÁÐÃû1>] ÀàÐÍ (³¤¶È) [ȱʡֵ][Áм¶Ô¼Êø]
[£¬<ÁÐÃû2> Êý¾ÝÀàÐÍ[ȱʡֵ][Áм¶Ô¼Êø]]….
[£¬UNIQUE£¨ÁÐÃû[£¬ÁÐÃû]….£©]
[£¬PRIMARY KEY£¨ÁÐÃû[£¬ÁÐÃû]…£©]
[£¬FOREIGN KEY £¨ÁÐÃû[£¬ÁÐÃû]…£©
REFERENCES ±íÃû£¨ÁÐÃû[£¬ÁÐÃû]…£©]
[£¬CKECK (Ìõ¼þ)] )
¹¦ÄÜ£º
½¨Á¢Ò»¸öÒÔ<±íÃû>ΪÃûµÄ±í¡£
/*´´½¨½èÊ黹ÊéÊý¾Ý¿â*/
create database ½èÊ黹ÊéÐÅÏ¢
on
( name = N'½èÊ黹ÊéÐÅÏ¢Data',
filename = N'D:\½èÊ黹ÊéÐÅÏ¢.mdf',
size = 20Mb,
maxsize = 40Mb,
filegrowth = 10Mb
)
log on
( name = N'½èÊ黹ÊéÐÅÏ¢_Log',
filename = N'D:\½èÊ黹ÊéÐÅÏ¢_Log.ldf',
size = 20Mb,
maxsize = 35Mb,
filegrowth = 10Mb
)
collate SQL_Latin1_General_CP1_CI_AS
go
/*´´½¨Êý¾Ý±í*/
use ½èÊ黹ÊéÐÅÏ¢
go
create table dbo.ͼÊé
(
ͼÊé±àºÅ int identity(1,1) not null ,
ͼÊéÃû³Æ varchar(50),
×÷Õß varchar(20),
³ö°æÉç varchar(50),
±¸×¢ varchar(100),
primary key (ͼÊé±àºÅ)
);
create table dbo.Óû§
(
Óû§±àºÅ int identity(1,1) not null,
¿ÚÁî varchar(20),
ÐÕÃû varchar(20),
ÐÔ±ð bit,
³öÉúÄêÔÂ datetime,
ÕË»§Óà¶î money,
primary key (Óû§±àºÅ)
);
CREATE TABLE [dbo].[½èÊé¼Ç¼]
(
[¼Ç¼±àºÅ] [int] IDENTITY(1,1) NOT NULL,
[Óû§±àºÅ] [int] NOT NULL,
[ͼÊé±àºÅ] [int] NOT NULL,
[½èÊéʱ¼ä] [datetime] NULL,
[»¹Êéʱ¼ä] [datetime] NULL,
[ÊÇ·ñÇ··Ñ] [bit] NULL,
[Ç··Ñ½ð¶î] [bit] NULL,
[ÊÇ·ñ»¹Êé] [bit] NULL,
PRIMARY KEY (¼Ç¼±àºÅ),
foreign key (Óû§±àºÅ) references Óû§(Óû§±àºÅ),
foreign key (ͼÊé±àºÅ) references ͼÊé(ͼÊé±àºÅ)
);
/*´´½¨Ë÷Òý*/
/****** ¶ÔÏó: Index [Book_ID_Name_Index] ½Å±¾ÈÕÆÚ: 09/26/2009 17:18:09 ******/
CREATE NONCLUSTERED INDEX [Book_ID_Name_Index] ON [dbo].[ͼÊé]
(
[ͼÊé±àºÅ] ASC,
[ͼÊéÃû³Æ] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = O
Ïà¹ØÎĵµ£º
select * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','1984-04-18',null);
UPDATE pet set birth='1989-08-31' WHERE name='Slim';
select * from pet WHERE birth>'1998-1-1';
SELECT * from pet WHEREselect * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','198 ......
Óï¾äÐÎʽ£º¡¡ SELECTTOP10*
fromTestTable
WHERE(ID>
¡¡¡¡¡¡¡¡¡¡(SELECTMAX(id)
¡¡¡¡¡¡¡¡from(SELECTTOP20id
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fromTestTable
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ORDERBYid)AST))
ORDERBYID
SELECTTOPÒ³´óС*
fromTestTable
WHERE(ID>
¡¡¡¡¡¡¡¡¡¡(SELECTMAX(id)
¡¡¡¡¡¡¡¡from(SELECTTOPÒ³´óС*Ò³Êýid
¡¡¡¡¡ ......
QZone Editor
.dump{}
//TODO ÓòÃû
if (location.hash) {
document.domain=location.hash.substr(1);
}
//parent.qZEditor.callback();
function init(){
//»ñÈ¡±à¼Æ÷Ãæ°åID
var pid = frameElement.panelID;
//»ñÈ¡±à¼Æ÷Ãæ°å¶ÔÏó
......
BEGIN TRANSACTION--¿ªÊ¼ÊÂÎñ
DECLARE @errorSun INT --¶¨Òå´íÎó¼ÆÊýÆ÷
SET @errorSun=0 --û´íΪ0
UPDATE a SET id=232 WHERE a=1 --ÊÂÎñ²Ù×÷SQLÓï¾ä
SET @errorSun=@errorSun+@@ERROR --ÀÛ¼ÆÊÇ·ñÓдí
UPDATE aa SET id=2 WHERE a=1 --ÊÂÎñ²Ù×÷SQLÓï¾ä
SET @errorSun=@errorSun+@@ERROR --ÀÛ¼ÆÊÇ·ñÓдí
I ......
if exists(select 1 from sysobjects where name='char_index')
drop function char_index
create function char_index(@string varchar(8000),@char varchar(10),@index smallint)
--@string:´ý²éÕÒ×Ö·û´®£¬@index:²éÕÒλÖÃ
returns smallint
as
begin
declare
@i tinyint,--µ±Ç°ÕÒµ½µÚ@i¸ö
  ......