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

¡¾SQL¡¿Ê¹ÓÃÒ»ÌõINSERTÓï¾äÍê³É¶à±í²åÈë

ÕâÊÇÒ»Ìõµß¸²³£¹æµÄ²åÈë·½·¨£¬Ò»ÌõINSERTÓï¾ä¿ÉÒÔÍê³ÉÏò¶àÕűíµÄ²åÈëÈÎÎñ¡£Ð¡Ð¡µØչʾһÏÂÕâÖÖ²åÈë·½·¨¡£
1.´´½¨±íT²¢³õʼ»¯²âÊÔÊý¾Ý£¬´Ë±í×÷ΪÊý¾ÝÔ´¡£
sec@ora10g> create table t (x number(10), y varchar2(10));
sec@ora10g> insert into t values (1,'a');
sec@ora10g> insert into t values (2,'b');
sec@ora10g> insert into t values (3,'c');
sec@ora10g> insert into t values (4,'d');
sec@ora10g> insert into t values (5,'e');
sec@ora10g> insert into t values (6,'f');
sec@ora10g> commit;
2.²é¿´±íTµÄÊý¾Ý
sec@ora10g> select * from t;
         X Y
---------- ----------
         1 a
         2 b
         3 c
         4 d
         5 e
         6 f
6 rows selected.
3.´´½¨±íT1ºÍT2£¬×÷ΪÎÒÃÇÒª²åÈëµÄÄ¿±ê±í¡£
sec@ora10g> create table t1 as select * from t where 0=1;
Table created.
sec@ora10g> create table t2 as select * from t where 0=1;
Table created.
4.µÚÒ»ÖÖ¶à±í²åÈë·½·¨INSERT ALL
1£©Íê³ÉINSERT ALL²åÈë
sec@ora10g> insert all into t1 into t2 select * from t;
12 rows created.
ÕâÀïÖ®ËùÒÔÏÔʾ²åÈëÁË12ÌõÊý¾Ý£¬Êµ¼ÊÉϱíʾÔÚT1±íÖвåÈëÁË6Ìõ£¬T2±í²åÈëÁË6Ìõ£¬Ò»¹²ÊÇ12ÌõÊý¾Ý¡£
2£©ÑéÖ¤T1±íÖб»²åÈëµÄÊý¾Ý¡£
sec@ora10g> select * from t1;
         X Y
---------- ----------
         1 a
         2 b
         3 c
         4 d
         5 e
         6 f
6 rows selected.
3£©ÑéÖ¤T2±íÖб»²åÈëµÄÊý¾Ý¡£
sec@ora10g> select * from t2;
         X Y
-


Ïà¹ØÎĵµ£º

ASP.NETºÍSQL Server 2005Á¬½Ó³öÏֵĴíÎóÒÔ¼°½â¾ö°ì·¨

ÎҲſªÊ¼¿´ASP.NETÓëÊý¾Ý¿âµÄÁ¬½Ó£¬½ñÌìÒ»¿ªÊ¼¾ÍÒ»Á¬Óöµ½Èý¸öÎÊÌ⣬ÕÛÌÚÁËÒ»ÍíÉÏ...Ï£ÍûÎҲ鵽µÄ×ÊÁ϶Դó¼ÒÓÐÓá£
×î³õÎÒдµÄÓï¾äÊÇ£º
//Create the Connection
//SqlConnection conn = new SqlConnection(@"Data Source=(local)\NetSDK; Initial Catalog=Northwind; User ID = sa; password = yourPassword;");
ÉÏÃæÕâ ......

SQL²Ù×÷È«¼¯


ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE da ......

SqlÓï¾ä´´½¨±í

н¨±í£º
create table [±íÃû]
(
[×Ô¶¯±àºÅ×Ö¶Î] int IDENTITY (1,1) PRIMARY KEY ,
[×Ö¶Î1] nVarChar(50) default \'ĬÈÏÖµ\' null ,
[×Ö¶Î2] ntext null ,
[×Ö¶Î3] datetime,
[×Ö¶Î4] money null ,
[×Ö¶Î5] int default 0,
[×Ö¶Î6] Decimal (12,4) default 0,
[×Ö¶Î7] image null ,
)
ɾ³ý±í£º
Drop table [ ......

SQLÖеÄLIKEÓï¾äµÄÓ÷¨

ÔÚSQL½á¹¹»¯²éѯÓïÑÔÖУ¬LIKEÓï¾äÓÐ×ÅÖÁ¹ØÖØÒªµÄ×÷Óá£
¡¡¡¡LIKEÓï¾äµÄÓï·¨¸ñʽÊÇ£ºselect * from ±íÃû where ×Ö¶ÎÃû like ¶ÔÓ¦Öµ£¨×Ó´®£©£¬ËüÖ÷ÒªÊÇÕë¶Ô×Ö·ûÐÍ×ֶεģ¬ËüµÄ×÷ÓÃÊÇÔÚÒ»¸ö×Ö·ûÐÍ×Ö¶ÎÁÐÖмìË÷°üº¬¶ÔÓ¦×Ó´®µÄ¡£
¡¡¡¡¼ÙÉèÓÐÒ»¸öÊý¾Ý¿âÖÐÓиö±ítable1£¬ÔÚtable1ÖÐÓÐÁ½¸ö×ֶΣ¬·Ö±ðÊÇnameºÍsex¶þÕßÈ«ÊÇ×Ö·ûÐÍÊý¾ ......

SQL²Ù×÷

QL·ÖÀࣺ
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¡¢ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ