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

Sql²Ù×÷´óÈ«

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ÀàÐ͵ij¤¶È¡£
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
×¢£ºË÷ÒýÊDz»¿É¸ü¸ÄµÄ£¬Ïë¸ü¸Ä±ØÐëɾ³ýÖØн¨¡£
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 fr


Ïà¹ØÎĵµ£º

SQL SERVER 2008 ±íÖµ²ÎÊý

/*
SQL SERVER 2008 ±íÖµ²ÎÊý
 
    SQL SERVER ÒýÈëÁË¿¹ÒéÓÃÀ´½«Ðм¯´«Èëµ½´æ´¢¹ý³ÌºÍÓû§¶¨Ò庯ÊýµÄ±íÖµ²ÎÊý.
Õâ¸ö¹¦ÄÜ¿ÉÒÔʹ´æ´¢¹ý³ÌºÍº¯Êý¾ßÓзâ×°¶à¸öÐм¯µÄ¹¦ÄÜ,¶ø²»ÊDZØÐëÒ»ÐÐÒ»Ðеص÷
Êý¾ÝÐ޸Ĺý³ÌºÍ´©¼þ¶à¸öÊäÈë²ÎÊýÀ´ÉúÓ²µÄת»¯Îª¶àÐÐ.
 
    ÎÒÃÇÔÚÓ¦ÓÃÖо­³£Óà ......

ÈçºÎÓà SQL Tuning Advisor (STA) ÓÅ»¯SQLÓï¾ä


ÔÚOracle10g֮ǰ£¬ÓÅ»¯SQLÊǸö±È½Ï·ÑÁ¦µÄ¼¼Êõ»î£¬²»Í£µÄ·ÖÎöÖ´Ðмƻ®£¬¼Óhint£¬·ÖÎöͳ¼ÆÐÅÏ¢µÈµÈ¡£ÔÚ10gÖУ¬OracleÍƳöÁË×Ô¼ºµÄSQLÓÅ»¯¸¨Öú¹¤¾ß: SQLÓÅ»¯Æ÷(SQL Tuning Advisor £ºSTA)£¬ËüÊÇеÄDBMS_SQLTUNE°ü¡£Ê¹ÓÃSTAÒ»¶¨Òª±£Ö¤ÓÅ»¯Æ÷ÊÇCBOģʽÏ¡£
Ö´ÐÐDBMS_SQLTUNE°ü½øÐÐsqlÓÅ»¯ÐèÒªÓÐadvisorµ ......

oracle ³£ÓÃÐÔÄܲéѯSQL·ÖÏí

select count(1) from dictionary;
select * from dba_data_files;
select count(1) from dba_objects t where t.owner='BESTTONE';
select * from dba_tablespaces t where t.tablespace_name='BESTTONE';
select count(1) from dba_tables t where t.owner='BESTTONE';
select t.table_name,t.comments from diction ......

SQL ServerÖеÄÃüÃû¹ÜµÀ(named pipe)¼°ÆäʹÓÃ

1. ʲôÊÇÃüÃû¹ÜµÀ£¿
ÓëTCP/IP£¨´«Êä¿ØÖÆЭÒé»òinternetЭÒ飩һÑù£¬ÃüÃû¹ÜµÀÊÇÒ»ÖÖͨѶЭÒé¡£ËüÒ»°ãÓÃÓÚ¾ÖÓòÍøÖУ¬ÒòΪËüÒªÇó¿Í»§¶Ë±ØÐë¾ßÓзÃÎÊ·þÎñÆ÷×ÊÔ´µÄȨÏÞ¡£
Òª½âÊÍÕâ¸öÎÊÌ⣬ÎÒ»¹ÊÇժ¼΢Èí¹Ù·½µÄ×ÊÁϱȽϺÃ
http://msdn.microsoft.com/zh-cn/library/ms187892.aspx
ÈôÒªÁ¬½Óµ½ SQL Server Êý¾Ý¿âÒýÇ棬±ØÐëÆô ......

SQL ×Ö¶Î帶¿Õ

SELECT * from xcmis.temp_odr_prom@linkxceis where trim(ODR_NO) like 'CA10010082'
SELECT * from xcmis.temp_odr_prom@linkxceis where ODR_NO like 'CA10010082%'
SELECT * from xcmis.temp_odr_prom@linkxceis where ODR_NO = 'CA10010082'
OK
SELECT * from xcmis.temp_odr_prom@linkxceis where ODR_NO like 'C ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ