Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : sql

SQL×Ö·û´®²Ù×÷º¯Êý´óÈ«

selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔ­ÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'ÔÆ',×Ö¶Î1£©=1;
×Ö·û´®º¯Êý¶Ô¶þ½øÖÆÊý¾Ý¡¢×Ö·û´®ºÍ±í´ïʽִÐв»Í¬µÄÔËËã¡£´ËÀຯÊý×÷ÓÃÓÚCHAR¡¢VARCHAR¡¢ BINARY¡¢ ºÍVARBINARY Êý¾ÝÀàÐÍÒÔ¼°¿ÉÒÔÒþʽת»»ÎªCHAR »òVARCHARµÄÊý¾ÝÀàÐÍ¡£¿ÉÒÔÔÚSELECT Óï¾äµÄSELECT ºÍWHERE ×Ó¾äÒÔ¼°±í´ïʽÖÐʹÓÃ×Ö·û´®º¯Êý¡£
³£ÓõÄ×Ö·û´®º¯ÊýÓУº
Ò»¡¢×Ö·ûת»»º¯Êý
1¡¢ASCII()
·µ»Ø×Ö·û±í´ïʽ×î×ó¶Ë×Ö·ûµÄASCII ÂëÖµ¡£ÔÚASCII£¨£©º¯ÊýÖУ¬´¿Êý×ÖµÄ×Ö·û´®¿É²»ÓÑ’À¨ÆðÀ´£¬µ«º¬ÆäËü×Ö·ûµÄ×Ö·û´®±ØÐëÓÑ’À¨ÆðÀ´Ê¹Ó㬷ñÔò»á³ö´í¡£
2¡¢CHAR()
½«ASCII Âëת»»Îª×Ö·û¡£Èç¹ûûÓÐÊäÈë0 ~ 255 Ö®¼äµÄASCII ÂëÖµ£¬CHAR£¨£© ·µ»ØNULL ¡£
3¡¢LOWER()ºÍUPPER()
LOWER()½«×Ö·û´®È«²¿×ªÎªÐ¡Ð´£»UPPER()½«×Ö·û´®È«²¿×ªÎª´óд¡£
4¡¢STR()
°ÑÊýÖµÐÍÊý¾Ýת»»Îª×Ö·ûÐÍÊý¾Ý¡£
STR (<float_expression>[£¬length[£¬ <decimal>]])
length Ö¸¶¨ ......

SQLÓαê¿ìËÙÉÏÊÖ

ÎÊÌâÃèÊö£ºÓÐÒÔÏÂ2ÕÅ±í£¬
      
                            ±íA
      
                            ±íB
       ÏÖÔÚÏ£ÍûµÃµ½ÕâÑùµÄÊý¾Ý±íAÀïµÄO_Saloary¼ÓÉϱíBµÄA_SalaryÊǵ±Ç°µÄ×ܹ¤×Ê£¬²¢¸üе½±íA¡£
       Äã¿ÉÒÔÓÃÊÓͼÀ´£¬±íÁ¬½ÓϾͿÉÒÔ¡£
       ÏÖÔÚÎÒÃÇ¿¼ÂÇÏÂÈÃSQL×Ô¼ºÀ´´¦Àí£¬Óαê¾ÍÊǺܺõķ½·¨¡£
       
      Ô­Àí£ºÓαê¾ÍÊÇ°ÑÊý¾Ý°´ÕÕÖ¸¶¨ÒªÇóÌáÈ¡³öÏàÓ¦µÄÊý¾Ý¼¯£¬È»ºóÖðÌõ½øÐÐÊý¾Ý´¦Àí¡£
      1.1ÓαêµÄ¸ÅÄî
       Óαê(Cursor)ËüʹÓû§¿ÉÖðÐзÃÎÊÓÉSQL Server·µ» ......

sqlÓÅ»¯É¨Ã¤

1.oracleɨÃèµÄ˳ÐòΪ´Óϵ½ÉÏ£¬´ÓÓÒµ½×ó
           ËùÒÔÎÒÃÇÒª¾¡¿ÉÄܵİÑÊý¾ÝÉٵıí·ÅÔÚºóÃ棬½»²æ±í·ÅÔÚºóÃ棬×îÄܹýÂ˵ÄÌõ¼þ·ÅÔÚºóÃæ
2.²»ÒªÔÚË÷ÒýÉÏʹÓüÆËãºÍnot²Ù×÷·û
           Ë÷ÒýÒ»µ©²ÎÓë¼ÆËã»òʹÓÃÁËnot²Ù×÷·û£¬oracle½«»áºöÂÔÕâ¸öË÷Òý
3.¾¡Á¿Ê¹ÓÃinºÍand£¬¾¡Á¿±ÜÃâʹÓÃor£¬or»á²úÉú´óÁ¿µÄ¹ýÂË £¬Ö±½Óµ¼ÖÂÂß¼­¶Á´óÁ¿Ôö¼Ó
4.±ØҪʱʹÓÃautotrace(sqlplusÖÐÓÐЧ£¬PL/SQLÖÐÎÞЧ)
           ÃüÁset autotrace on;
           ¹æÔò£º¾¡Á¿¼õÉÙÂß¼­¶Á£¬Ó¦¸Ã±ÜÃâÎïÀí¶Á£¬Ìá¸ß»º³åÇøÃüÖÐÂÊ £¬×îºÃ±£³ÖÔÚ95%ÒÔÉÏ¡£
           recursive calls      µÝ¹éµ÷ÓÃ
           db block gets       Êý¾Ý¿é¶ÁÈ¡
           cons ......

Sqlite3³£ÓÃSQLÓï¾ä×ܽᣬһÊÇ·ÀÖ¹×Ô¼ºÍüÁË£¬¶þÊÇ·ÖÏí

ÎÄÖеÄSQL¶¼ÊÇ´ÓÎÒµÄÏîÄ¿ÖÐÖ±½Ócopy¹ýÀ´£¬Òò´ËºÜ¶à±íÃûʲô¶¼ÓÐÁË
//´´½¨±í
"CREATE TABLE FEED_TABLE(FeedID TEXT, Title TEXT, Summary TEXT, Author TEXT, ImageName VARCHAR(21), ImageType TEXT, MaxIndex INT, ImageData BLOB)"
//²éѯ¼Ç¼
"select * form 'table_name'"
"select * form 'table name' where value = '?'"
//²åÈë¼Ç¼
"INSERT INTO FEED_TABLE(FeedID, Title, Summary, ImageName, ImageType, MaxIndex) VALUES('%s', '%s', '%s', '%s', '%s', %d)"
//¸üмǼ
"update 'table_name' 'column_name' = 'value'"
//ɾ³ý¼Ç¼
"DELETE from FAVORITE_TABLE WHERE EntryIndex = %d"
//ɾ³ýËùÓмǼ
"delete from 'table_name'"
//ɾ³ý±í
"drop table 'table_name'"
//²éѯ±í½á¹¹
"select sql from sqlite_master where name = 'table_name'"
callbackµÄµÚÈý¸ö²ÎÊý
ÁíÍâ,sqlite3ÊÇÖ§³ÖÊÂÎñµÄ
int result;
result = sqlite3_exec( db, "begin transaction", 0, 0, &zErrorMsg ); //¿ªÊ¼Ò»¸öÊÂÎñ
result = sqlite3_exec( db, "commit transaction", 0, 0, &zErrorMsg ); //Ìá½»ÊÂÎñ
result = sqlite3_exec( db, "rollback tran ......

Sqlite3³£ÓÃSQLÓï¾ä×ܽᣬһÊÇ·ÀÖ¹×Ô¼ºÍüÁË£¬¶þÊÇ·ÖÏí

ÎÄÖеÄSQL¶¼ÊÇ´ÓÎÒµÄÏîÄ¿ÖÐÖ±½Ócopy¹ýÀ´£¬Òò´ËºÜ¶à±íÃûʲô¶¼ÓÐÁË
//´´½¨±í
"CREATE TABLE FEED_TABLE(FeedID TEXT, Title TEXT, Summary TEXT, Author TEXT, ImageName VARCHAR(21), ImageType TEXT, MaxIndex INT, ImageData BLOB)"
//²éѯ¼Ç¼
"select * form 'table_name'"
"select * form 'table name' where value = '?'"
//²åÈë¼Ç¼
"INSERT INTO FEED_TABLE(FeedID, Title, Summary, ImageName, ImageType, MaxIndex) VALUES('%s', '%s', '%s', '%s', '%s', %d)"
//¸üмǼ
"update 'table_name' 'column_name' = 'value'"
//ɾ³ý¼Ç¼
"DELETE from FAVORITE_TABLE WHERE EntryIndex = %d"
//ɾ³ýËùÓмǼ
"delete from 'table_name'"
//ɾ³ý±í
"drop table 'table_name'"
//²éѯ±í½á¹¹
"select sql from sqlite_master where name = 'table_name'"
callbackµÄµÚÈý¸ö²ÎÊý
ÁíÍâ,sqlite3ÊÇÖ§³ÖÊÂÎñµÄ
int result;
result = sqlite3_exec( db, "begin transaction", 0, 0, &zErrorMsg ); //¿ªÊ¼Ò»¸öÊÂÎñ
result = sqlite3_exec( db, "commit transaction", 0, 0, &zErrorMsg ); //Ìá½»ÊÂÎñ
result = sqlite3_exec( db, "rollback tran ......

SQL express °²×°ÊֲᣭÏÂÔØ

1¡¢ÏÂÔØ£ºÐèÒªÏÂÔØ2¸öÎļþ¡£ 1) sql server express studioÏÂÔصØÖ·£º Microsoft SQL Server Management Studio Express http://www.microsoft.com/downloads/details.aspx?FamilyID=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796&displaylang=zh-cn ÔÙÏÂÔØ£º 2£©Microsoft SQL Server 2005 Express Edition http://www.microsoft.com/downloads/details.aspx?familyid=220549B5-0B07-4448-8848-DCC397514B41&displaylang=zh-cn   ......

OracleÖÐÓÃÒ»¾äSQLÓï¾äʵÏÖÐÐÁÐת»»

SQL*PLus>   desc   emp;  
    Ãû³Æ                                                                             ÊÇ·ñΪ¿Õ?   ÀàÐÍ  
    -----------------------------------------   --------   -----------------------  
    EMPNO                                                                                             NUMBER(4)  
    ENAME                                           ......

OracleÖÐÓÃÒ»¾äSQLÓï¾äʵÏÖÐÐÁÐת»»

SQL*PLus>   desc   emp;  
    Ãû³Æ                                                                             ÊÇ·ñΪ¿Õ?   ÀàÐÍ  
    -----------------------------------------   --------   -----------------------  
    EMPNO                                                                                             NUMBER(4)  
    ENAME                                           ......
×ܼǼÊý:4346; ×ÜÒ³Êý:725; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [689] [690] [691] [692] 693 [694] [695] [696] [697] [698]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ