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