Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

sqlÓï¾äѧϰ±Ê¼Ç(8) Ìí¼ÓÔ¼Êø£¬ÊµÏÖÊý¾ÝÍêÕûÐÔ

USE StudentInfo
--=====================================================
--Author     £ºyangjuncheng  
--Create Date:2010.5.26
--Decription :¸ø±íÌí¼ÓÔ¼Êø£¨¿ÉÒÔÔÚ´´½¨±íʾֱ½ÓÌí¼Ó
--            Ò²¿ÉÒÔʹÓÃalter¹Ø¼ü×Ö¸øÒÑ´æÔڵıíÌí¼ÓÔ¼Êø
--=====================================================
--=====================================================
--±í½á¹¹ËµÃ÷
--tb_student(stu_id,stu_name,class_id,school_id,stu_address,stu_head,stu_age)
--ÆäÖÐstu_headΪvarbinaryÀàÐÍ£¬´æ·ÅѧÉúµÄµç×ÓÕÕÆ¬
--tb_school(schoo_id,school_name)
--tb_class(class_id,class_name)
--=====================================================
--checkÔ¼Êø£ºÏÞÖÆÑ§ÉúµÄÄêÁ䱨ÐëÔÚ0-100Ö®¼ä
ALTER TABLE tb_student
ADD constraint CK_stu_age CHECK(stu_age>0 AND stu_age<100)
--Ö÷¼üÔ¼Êø£º¸øÑ§Éú±íÌí¼ÓÒ»¸öÖ÷¼üÔ¼Êø
ALTER TABLE tb_student
ADD CONSTRAINT PK_stu_id PRIMARY KEY (stu_id)
--Íâ¼üÔ¼Êø£ºÑ§Éú±íµÄ°à¼¶idÒýÓð༶±íÖеÄid
ALTER TABLE tb_student
ADD CONSTRAINT FK_class_id FOREIGN KEY (class_id) REFERENCES tb_class(class_id)
--Ìí¼ÓĬÈÏÔ¼Êø£ºÑ§ÉúĬÈϵØÖ·Îª‘Öйú’
ALTER TABLE tb_student
ADD CONSTRAINT DF_stu_address DEFAULT('Öйú') for stu_address
--Ìí¼ÓÎ¨Ò»Ô¼Êø£ºÖ¸¶¨Ñ§ÉúÃûΨһÐÔ
ALTER TABLE tb_student
ADD CONSTRAINT UQ_stu_name UNIQUE(stu_name)


Ïà¹ØÎĵµ£º

SQL ServerÖÐÁÙʱ±íÓë±í±äÁ¿µÄÇø±ð

ÎÒÃÇÔÚÊý¾Ý¿âÖÐʹÓñíµÄʱºò,¾­³£»áÓöµ½Á½ÖÖʹÓñíµÄ·½·¨,·Ö±ð¾ÍÊÇʹÓÃÁÙʱ±í¼°±í±äÁ¿¡£ÔÚʵ¼ÊʹÓõÄʱºò£¬ÎÒÃÇÈçºÎÁé»îµÄÔÚ´æ´¢¹ý³ÌÖÐÔËÓÃËüÃÇ£¬ËäÈ»ËüÃÇʵÏֵŦÄÜ»ù±¾ÉÏÊÇÒ»ÑùµÄ£¬¿ÉÈçºÎÔÚÒ»¸ö´æ´¢¹ý³ÌÖÐÓÐʱºòȥʹÓÃÁÙʱ±í¶ø²»Ê¹Óñí±äÁ¿£¬ÓÐʱºòȥʹÓñí±äÁ¿¶ø²»Ê¹ÓÃÁÙʱ±íÄØ?
¡¡¡¡ÁÙʱ±í
¡¡¡¡ÁÙʱ±íÓëÓÀ¾Ã±íÏàËÆ£ ......

ÔõÑù½«excelÖеÄÊý¾Ýͨ¹ýPL/SQLµ¼ÈëORACLEÊý¾Ý¿âÖÐ

ÏêϸµØ²½Öè:


1¡¢´ò¿ªMicroSoft   Excel   2000  


2¡¢Îļþ(F)→н¨(N)→¹¤×÷²¾→  


3¡¢ÊäÈëÊý¾Ýºó£¬´æÅÌΪtest.xls£¬  


4¡¢Îļþ(F)→Áí´æÎª(A)→  


±£´æÀàÐÍΪ£ºÖƱí·û·Ö¸ô£¬ÆðÃûΪtext.txt£¬±£´æµ½C:\ &nb ......

SQL Server ѹËõÈÕÖ¾¿Õ¼ä

ʹÓÃÁËÒ»¶Îʱ¼äºó£¬SQL Server µÄ LDFÎļþÌå»ý¾Þ´ó.
ÈçºÎ´¦ÀíàÏ, ¶ÔÓÚ SQL Server 2005 ¼°Ö®Ç°µÄ°æ±¾£¬¿ÉÒÔʹÓÃÈçÏ SQL£º
declare @name varchar(50)
set @name='dbname
'
backup
log @name
with truncate_only
dbcc shrinkdatabase (@name,20)
¿ÉÊÇÔÚ SQL Server 2008 ¿ªÊ¼£¬Ö´ÐÐÉÏÃæµÄÓï¾ä»á±¨´í:
'truncate ......

SQL SERVER 2008 ѹËõ±¸·Ý

/*
    SQL SERVER 2008 ѹËõ±¸·Ý
 
 
 
    SQL SERVER 2008 ÔÚÆóÒµ°æºÍ¿ª·¢°æÖÐÒýÈëÁ˱¸·ÝѹËõ.ʹÓÃÕ߸ö¹¦ÄÜ¿ÉÒÔ¸ü¿ìËٵı¸·ÝÊý¾Ý¿â²¢ÇÒ
    ÏûºÄ¸üÉٵĴÅÅ̿ռä.ѹËõÁ¿ÒÀÀµÓÚÊý¾Ý¿âÖд洢µÄÊý¾Ý.ÀýÈç,º¬ÓÐÖØ¸´Öµ×Ö·ûÊý¾ÝµÄÊý¾Ý¿â¿ÉÒÔÓÐ
   ......

aspÍøÒ³Àï,sql³£ÓòÙ×÷Óï¾ä!

Ìí¼Ó¡¢É¾³ý¡¢ÐÞ¸ÄʹÓÃ
db.Execute(Sql)ÃüÁîÖ´ÐвÙ×÷
╔----------------╗
¡î Êý¾Ý¼Ç¼ɸѡ ¡î
╚----------------╝
×¢Ò⣺µ¥Ë«ÒýºÅµÄÓ÷¨¿ÉÄÜÓÐÎó(ûÓвâʽ)
 
Sql = "Select
Distinct
×Ö¶ÎÃû from Êý¾Ý±í"
Distinctº¯Êý£¬²éѯÊý¾Ý¿â´æ±íÄÚ²»Öظ´µÄ¼Ç¼
 
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ