SQLÊý¾Ý¿â³£ÓÃÃüÁî ´´½¨,ɾ³ý±í Ìí¼Ó,ÐÞ¸Ä,ɾ³ý×Ö¶Î
SQLÊý¾Ý¿â³£ÓÃÃüÁî-´´½¨,ɾ³ý±í-Ìí¼Ó,ÐÞ¸Ä,ɾ³ý×Ö¶Î
http://blog.csdn.net/cncco/archive/2009/08/08/4424555.aspx
'´´½¨±í
CREATE TABLE dbo£®CategoriesNew
(CategoryID intIDETITY (1£¬1) NOT NULL£¬
CategoryName nvarchar(15) NOT NULL£¬
Description ntext NULL£¬
Picture image NULL)
'ɾ³ý±í
DROP TABLE table_name[,...n]
'Ôö¼Ó×Ö¶Î
addsqlstr = "alter table docdsp add dspcode char(200)"
'ɾ³ý×Ö¶Î
delsqlstr = "ALTER TABLE table_NAME DROP COLUMN column_NAME"
'ÐÞ¸Ä×Ö¶ÎÀàÐÍ
editsqlstr = "ALTER TABLE table_name ALTER COLUMN column_name new_data_type"
Ïêϸ˵Ã÷£º
3.2 ´´½¨±í
ÔÚ¶¨ÒåÁ˱íµÄËùÓÐÊý¾ÝÀàÐÍÖ®ºó£¬¾Í¿ÉÒÔ´´½¨±í¡¢Ìí¼ÓºÍɾ³ýÁС¢ÒÔ¼°Éú³ÉÁÐÖµÁË¡£
3.2.3 ´´½¨ºÍɾ³ý±í
1¡¢´´½¨±íµÄ»ù±¾ÒªÇó
´´½¨±íʱ±ØÐëÖ¸¶¨±íÃû¡¢ÁÐÃûÒÔ¼°Êý¾ÝÀàÐÍ¡£¶Ô¸ø¶¨µÄ±íÀ´Ëµ£¬ÁÐÃû±ØÐëΨһ£¬µ«ÊÇ£¬Í¬Ò»¸öÊý¾Ý¿âÖв»Í¬±íµÄÁеÄÃû³Æ¿ÉÒÔÏàͬ¡£±ØÐëΪÿһÁж¼Ö¸¶¨Êý¾ÝÀàÐÍ¡£
ÒÔÏÂÊÇÔÚSQL ServerÖд´½¨±íµÄ¼«ÏÞ£º
ÿ¸öÊý¾Ý¿âÖпÉÒÔÓÐ20ÒÚ¸ö±í¡£
ÿ¸ö±í¿ÉÒÔÓÐ1024¸öÁС£
ÿ¸öÁпÉÒÔÓÐ8060×Ö½Ú(ÕâÒ»—½üËÆµÄ×î´ó³¤¶È²»ÊÊÓÃÓÚtext¡¢ntextºÍimageÊý¾ÝÀàÐÍ)¡£
2¡¢ÁÐÕûÐò(Column Collation)
SQL ServerÖ§³ÖÔÚͬһ¸öÊý¾Ý¿âÖÐÒÔ²»Í¬µÄÕûÐò·½Ê½´æ´¢¶ÔÏó¡£²»Í¬µÄSQL ServerÕûÐò·½Ê½¿ÉÒÔÔÚÁм¶Ö¸¶¨£¬ÕâÑù£¬±íÖеÄÿ¸öÁж¼¿ÉÒÔÖ¸¶¨²»Í¬µÄÕûÐò·½Ê½¡£
3¡¢Ö¸¶¨NULL»òNOT NULL
ÎÒÃÇ¿ÉÒÔÔÚ±í¶¨ÒåÖÐÖ¸¶¨ÔÚÿ¸öÁÐÉÏÊÇ·ñÔÊÐí¿ÕÖµ¡£Èç¹ûδָ¶¨NULL»òNOT NULL£¬SQL Server¸ù¾Ý»á»°¼¶»òÊý¾Ý¿â¼¶µÄȱʡÉèÖÃÌṩÏàÓ¦µÄNULL»òNOT NULLÌØÐÔ¡£µ«ÊÇ£¬ÕâЩȱʡÉèÖÿÉÄܻᷢÉú±ä»¯£¬Òò´Ë£¬²»ÒªÒÀÀµÕâЩȱʡÉèÖá£NOT NULLÊÇSQL ServerµÄȱʡÉèÖá£
4¡¢´´½¨±íµÄ²¿·ÖÓï·¨
CREATE TABLE table_name
column_name datatype [COLLATE<collation_name>]
[NULL|NOT NULL]
| column_name AS computed_column_expression
[,...n]
ÏÂÃæµÄÀý×Ó´´½¨ÁËÒ»¸ödbo.CategoriesNew±í£¬Í¬Ê±ÃèÊöÁ˱íÖеÄÁУ¬Ã¿ÁеÄÊý¾ÝÀàÐͺÍÿÁÐÊÇ·ñÔÊÐíΪNullÖµ¡£
CREATE TABLE dbo£®CategoriesNew
(CategoryID intIDETITY (1£¬1) NOT NULL£¬
CategoryName nvarchar(15) NOT NULL£¬
Description ntext NULL£¬
Picture image NULL)
×¢Ò⣺Äã¿ÉÒÔʹÓÃSQL Server Enterprise Manager»òÖ´ÐÐsp_helpϵͳ´æ´¢
Ïà¹ØÎĵµ£º
ÓÃSQLÃüÁî²éѯÊÓͼ¶¨ÒåÓï¾ä£¬¿ÉÒÔÓÃÒÔÏÂÁ½ÖÖ·½·¨£º
sp_helptext 'ÊÓͼÃû' --¶àÐÐÏÔʾ
SELECT text from sysobjects so INNER JOIN syscomments sc ON so.id=sc.id WHERE so.id=OBJECT_ID('ÊÓͼÃû')--µ¥ÐÐÏÔʾ
......
ÔÚÍøÉÏÕÒÁËºÃ¶à¹ØÓÚSqlServer2005תaccessµÄ·½·¨£¬´ó¶à¶¼ÊÇÓÃsqlÓï¾ä£¬¶øÎÒ²»ÏëÓÃÄÇÖÖ·½·¨£¬ÓÚÊÇÎÒ×Ô¼ºÃþË÷³öÀ´ÈçºÎ½«SqlServerÊý¾Ý¿âת»»³Éaccess£¬·½·¨¿ÉÄÜÓе㱿£¬²»¹ýÍê³ÉÁËת»»µÄ¹¦ÄÜ¡£ÏÂÃæÊǾßÌå²½Ö裺
1.´ò¿ªAccess£¬½¨Á¢Ò»¸öºó׺ÃûΪ.mdbµÄ¿ÕµÄÊý¾Ý¿âÎļþ£¨Ä¬ÈϺó׺¿ÉÄÜÊÇ.accdb,ÎÒÃǰÑËü¸ÄΪ.mdb¾Í¿ÉÒÔÁË£©£¬È»ºó ......
1.µÇ½ϵͳÓû§
sqlplus È»ºóÊäÈëϵͳÓû§ÃûºÍÃÜÂë
µÇ½±ðµÄÓû§
conn Óû§Ãû/ÃÜÂë;
2.´´½¨±í¿Õ¼ä
create tablespace ¿Õ¼äÃû
datafile 'c:"¿Õ¼äÃû' size 15M --±í¿Õ¼äµÄ´æ·Å·¾¶,³õʼֵΪ15M
autoExtend on next 10M --¿Õ¼äµÄ×Ô¶¯Ôö³¤µÄÖµÊÇ10M
permanent online; --ÓÀ¾ÃʹÓÃ
3.´´½¨Óû§
create user s ......
SQL Server ²éѯһÕűíµÄÖ÷¼ü
http://hi.baidu.com/samxx8/blog/item/7048f8de1725835894ee37b4.html
SELECT a.name
from syscolumns a
inner join sysobjects d on a.id=d.id
where d.name='SPF_Users' and exists(SELECT 1 from sysobjects where xtype=' ......
SQL×¢Èë¹¥»÷µÄΣº¦ÐԺܴó¡£ÔÚ½²½âÆä·ÀÖ¹°ì·¨Ö®Ç°£¬Êý¾Ý¿â¹ÜÀíÔ±ÓбØÒªÏÈÁ˽âÒ»ÏÂÆä¹¥»÷µÄÔÀí¡£ÕâÓÐÀûÓÚ¹ÜÀíÔ±²ÉÈ¡ÓÐÕë¶ÔÐԵķÀÖδëÊ©¡£
¡¡¡¡Ò»¡¢ SQL×¢Èë¹¥»÷µÄ¼òµ¥Ê¾Àý¡£
¡¡¡¡statement := "SELECT * from Users WHERE Value= " + a_variable + "
¡¡¡¡ÉÏÃæÕâÌõÓï¾äÊÇºÜÆÕͨµÄÒ»ÌõSQLÓï¾ä£¬ËûÖ÷ҪʵÏֵŦÄܾÍÊÇÈÃÓû§Ê ......