ÎÒÔÚ±±´óÇàÄñËùѧSQL֪ʶµÄС»ã×Ü
´´½¨Îļþ¼Ð£ºexec xp_cmdshell 'md ÅÌ·û:\Îļþ¼ÐÃû³Æ', no_output
ÀýÈ磺ÔÚDÅÌ´´½¨ÃûΪ£º“×ÊÁÏ”µÄÎļþ¼Ð£ºexec xp_cmdshell 'md d:\×ÊÁÏ', no_output
²é¿´Îļþ£ºexec xp_cmdshell 'dirÅÌ·û:\Îļþ¼ÐÃû³Æ'¡£ÀýÈ磺exec xp_cmdshell 'dir d:\×ÊÁÏ'
ÅжÏÊý¾Ý¿âÊÇ·ñ´æÔÚ£ºif exists(select * from sysdatabases where name='Êý¾Ý¿âÃû³Æ')
drop database Êý¾Ý¿âÃû³Æ
ÅжϱíÊÇ·ñ´æÔÚ——if exists(select * from sysobjects where name='±íÃû') drop table ±íÃû
Ìí¼ÓÔ¼Êø£¨5ÖÖ£©——Óï·¨£ºalter table ±íÃû add constraint Ô¼ÊøÃûÔ¼ÊøÀàÐÍ ¾ßÌåµÄÔ¼Êø˵Ã÷
1.Ö÷¼üÔ¼Êø£ºalter table ±íÃû add constraint pk_Ô¼ÊøÃû primary key(Ö÷¼üÔ¼Êø×Ö¶ÎÃû)
2.Íâ¼ü£ºalter table±íÃûadd constraint fk_Ô¼ÊøÃûforeign key(Íâ¼ü×Ö¶ÎÃû) references ¹Øϵ±í(Ö÷¼üÃû)
3.ΨһԼÊø£ºalter table ±íÃû add constraint uq_Ô¼ÊøÃû unique (ΨһԼÊø×Ö¶ÎÃû)
4.¼ì²éÔ¼Êø£ºalter table ±íÃû add constraint ck_Ô¼ÊøÃû check (Ô¼Êø¼ì²é×Ö¶ÎÃû) --±í´ïʽ
5.ĬÈÏÔ¼Êø£ºalter table ±íÃû add constraint df_Ô¼ÊøÃû default (ĬÈÏÖµ) for ĬÈÏÔ¼Êø×Ö¶ÎÃû
ɾ³ýÔ¼ÊøÓï·¨£ºalter table ±íÃû drop constraint Ô¼ÊøÃû
ÀýÈ磺ɾ³ýstuInfo±íÖеØÖ·µÄĬÈÏÔ¼Êø£ºalter table stuInfo drop constraint Ô¼ÊøÃû(df_stuAddress)
µÚÒ»µÀ´óÃÅ——´´½¨µÇ¼ÕÊ»§£¨2ÖÖ£©
µÚÒ»ÖÖ£ºSQLÕË»§£ºexec sp_addlogin 'Óû§Ãû','ÃÜÂë'
µÚ¶þÖÖ£ºWindowsÕË»§£ºexec sp_grantlogin 'windowsÓòÃû\ÓòÕË»§'
µÚ¶þµÀ´óÃÅ——´´½¨Êý¾Ý¿âÓû§ £ºexec sp_grantdbaccess 'µÇ¼ÕË»§','Êý¾Ý¿âÓû§'
--“Êý¾Ý¿âÓû§”Ϊ¿ÉÑ¡²ÎÊý£¬Ä¬ÈÏΪµÇ¼ÕË»§£¬¼´Êý¾Ý¿âÓû§Ä¬ÈϺ͵ǼÕË»§Í¬Ãû¡£
ÀýÈ磺ÔÚÊý¾Ý¿âÖÐÌí¼ÓÒ»¸öÓû§£º
exec sp_grantdbaccess 'zhang','zhangUser' --'zhangΪµÇ¼ÕË»§','zhangUserΪÊý¾Ý¿âÓû§'
µÚÈýµÀ´óÃÅ——ÏòÊý¾Ý¿âÓû§ÊÚȨ£ºgrant ȨÏÞ on ±íÃû to Êý¾Ý¿âÓû§
ÀýÈ磺ΪzhangsanUserÊÚÓè¶Ô±ístuInfoµÄÔöɾ¸Ã²éµÄȨÏÞ
grant select,update,delete,insert on stuInfo to zhangsanUser
½¨±íµÄȨÏÞ£ºgrant create table to zhangsanUser
----------------------------------µÚÈýÕ T—SQL±à³Ì--------
Ïà¹ØÎĵµ£º
1 £¬¶ÔÓÚÈÕÆÚ×Ö¶Î×Ö¶Î
access±íʾΪ£º#1981-28-12#
SQLSERVER2000±íʾΪ£º''1981-02-12''
2,SQLÓï¾äÇø±ð£¬select ,update ÔÚ¶Ôµ¥±í²Ù×÷ʱ¶¼²î²»¶à£¬
µ«¶à±í²Ù×÷ʱupdateÓï¾äµÄÇø±ðACCESSÓëSQLSERVERÖеÄUpdateÓï¾ä¶Ô±È:
SQLSERVERÖиüжà±íµÄUpdateÓï¾ä:
Update Tab1
SET a.Name = b.Name
from Tab1 a,Tab2 b
Whe ......
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â ......
Ò»¡¢°´Ö¸¶¨·ûºÅ·Ö¸î×Ö·û´®£¬·µ»Ø·Ö¸îºóµÄÔªËظöÊý£¬·½·¨ºÜ¼òµ¥£¬¾ÍÊÇ¿´×Ö·û´®ÖдæÔÚ¶àÉÙ¸ö·Ö¸ô·ûºÅ£¬È»ºóÔÙ¼ÓÒ»£¬¾ÍÊÇÒªÇóµÄ½á¹û¡£
CREATE function Get_StrArrayLength
(
@str varchar(1024), --Òª·Ö¸îµÄ×Ö·û´®
@split varchar(10) --·Ö¸ô·û ......
---- ÈËÃÇÔÚʹÓÃSQLʱÍùÍù»áÏÝÈëÒ»¸öÎóÇø£¬¼´Ì«¹Ø×¢ÓÚËùµÃµÄ½á¹ûÊÇ·ñÕýÈ·£¬¶øºöÂÔ
Á˲»Í¬µÄʵÏÖ·½·¨Ö®¼ä¿ÉÄÜ´æÔÚµÄÐÔÄܲîÒ죬ÕâÖÖÐÔÄܲîÒìÔÚ´óÐ͵ĻòÊǸ´ÔÓµÄÊý¾Ý¿â
»·¾³ÖУ¨ÈçÁª»úÊÂÎñ´¦ÀíOLTP»ò¾ö²ßÖ§³ÖϵͳDSS£©ÖбíÏÖµÃÓÈΪÃ÷ÏÔ¡£±ÊÕßÔÚ¹¤×÷ʵ¼ù
Öз¢ÏÖ£ ......
ÔÚPL/SQL¿éÖв»ÄÜÖ±½Óµ÷ÓÃDDLÓï¾ä£¬¿ÉÒÔÀûÓÃÏÂÃæµÄ·½·¨½øÐе÷ÓÃ
·½·¨Ò»£º¶¯Ì¬SQL
execute immediate 'CREATE TABLE newtable AS
&nb ......