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

ORACLEºÍSQLÓï·¨Çø±ð¹éÄÉ

¹Ø¼ü×Ö: oracle & sql server
Êý¾ÝÀàÐͱȽÏ
ÀàÐÍÃû³Æ
Oracle
SQLServer
±È½Ï
×Ö·ûÊý¾ÝÀàÐÍ CHAR CHAR ¶¼Êǹ̶¨³¤¶È×Ö·û×ÊÁϵ«oracleÀïÃæ×î´ó¶ÈΪ2kb£¬SQLServerÀïÃæ×î´ó³¤¶ÈΪ8kb
±ä³¤×Ö·ûÊý¾ÝÀàÐÍ VARCHAR2 VARCHAR OracleÀïÃæ×î´ó³¤¶ÈΪ4kb£¬SQLServerÀïÃæ×î´ó³¤¶ÈΪ8kb
¸ù¾Ý×Ö·û¼¯¶ø¶¨µÄ¹Ì¶¨³¤¶È×Ö·û´® NCHAR NCHAR Ç°Õß×î´ó³¤¶È2kbºóÕß×î´ó³¤¶È4kb
¸ù¾Ý×Ö·û¼¯¶ø¶¨µÄ¿É±ä³¤¶È×Ö·û´® NVARCHAR2 NVARCHAR ¶þÕß×î´ó³¤¶È¶¼Îª4kb
ÈÕÆÚºÍʱ¼äÊý¾ÝÀàÐÍ DATE ÓÐDatetimeºÍSmalldatetimeÁ½ÖÖ ÔÚoracleÀïÃæ¸ñʽΪDMYÔÚSQLSerserÀïÃæ¿ÉÒÔµ÷½Ú£¬Ä¬ÈϵÄΪMDY
Êý×ÖÀàÐÍ NUMBER(P,S) NUMERIC[P(,S)] OracleÀïÃæp´ú±íСÊýµã×óÃæµÄλÊý£¬s´ú±íСÊýµãÓÒÃæµÄλÊý¡£¶øSQLServerÀïÃæp´ú±íСÊýµã×óÓÒÁ½ÃæµÄλÊýÖ®ºÍ£¬s´ú±íСÊýµãÓÒÃæµÄλÊý¡£
Êý×ÖÀàÐÍ DECIMAL(P,S) DECIMAL[P(,S)] OracleÀïÃæp´ú±íСÊýµã×óÃæµÄλÊý£¬s´ú±íСÊýµãÓÒÃæµÄλÊý¡£¶øSQLServerÀïÃæp´ú±íСÊýµã×óÓÒÁ½ÃæµÄλÊýÖ®ºÍ£¬s´ú±íСÊýµãÓÒÃæµÄλÊý¡£
ÕûÊýÀàÐÍ INTEGER INT ͬΪÕûÊýÀàÐÍ£¬´æ´¢´óС¶¼Îª4¸ö×Ö½Ú
¸¡µãÊýÀàÐÍ FLOAT FLOAT
ʵÊýÀàÐÍ REAL REAL
ORACLEÄÚ²¿º¯Êý´óÈ«ÒÔ¼°ÓëSQLSERVERµÄÇø±ð£º
ÏÂÃæÊÇOracleÖ§³ÖµÄ×Ö·ûº¯ÊýºÍËüÃǵÄMicrosoft SQL ServerµÈ¼Ûº¯Êý¡£
º¯Êý Oracle Microsoft SQL¡¡Server
°Ñ×Ö·ûת»»ÎªASCII :ASCII ASCII
×Ö´®Á¬½Ó: CONCAT --------------(expression + expression)
°ÑASCIIת»»Îª×Ö·û CHR, CHAR
·µ»Ø×Ö·û´®ÖеĿªÊ¼×Ö·û£¨×óÆ𣩠INSTR ,---------------CHARINDEX
°Ñ×Ö·ûת»»ÎªÐ¡Ð´ LOWER ---------------------LOWER
°Ñ×Ö·ûת»»Îª´óд UPPER-------------------- UPPER
Ìî³ä×Ö·û´®µÄ×ó±ß LPAD --------------------N/A
Çå³ý¿ªÊ¼µÄ¿Õ°× LTRIM--------------------LTRIM
Çå³ýβ²¿µÄ¿Õ°× RTRIM --------------------RTRIM
×Ö·û´®ÖеÄÆðʼģʽ£¨pattern£© INSTR --------------------PATINDEX
¶à´ÎÖظ´×Ö·û´® RPAD --------------------REPLICATE
×Ö·û´®µÄÓïÒô±íʾ SOUNDEX --------------------SOUNDEX
Öظ´¿Õ¸ñµÄ×Ö´® RPAD --------------------SPACE
´ÓÊý×ÖÊý¾Ýת»»Îª×Ö·ûÊý¾Ý TO_CHAR --------------------STR
×Ó´® SUBSTR --------------------SUBSTRING
Ìæ»»×Ö·û REPLACE --------------------STUFF
½«×Ö´®ÖеÄÿ¸ö´ÊÊ××Öĸ´óд INITCAP --------------------N/A
·­Òë×Ö·û´® TRANSLATE


Ïà¹ØÎĵµ£º

NHibernateÖ´ÐÐԭʼSQL´úÂëµÄ·½·¨Ð¡½á

ÔÚʹÓÃNHibernate¹ý³ÌÖо­³£»áʹÓõ½¸´ÔÓµÄsql²éѯ£¬µ«ÊÇʹÓÃhqlÓֱȽÏÂé·³µÄÇé¿öÏ£¬ÎÒÃÇÍùÍù¶¼»áÏëµ½²ÉÓÃԭʼµÄsqlÀ´Ö´ÐС£µ«ÊÇÈçºÎÀûÓÃNHibernateÀ´Ö´ÐÐsqlÄØ£¿ÎÊÌâÀ´ÁË£¬ÔÚNHibernateÖÐÒ²ÓÐAdoTemplateµÄ·½·¨¿ÉÒÔÖ´ÐÐsqlµÄ£¬µ«ÊÇÕâÀïÒª½éÉܵÄÊÇÁíÍâÒ»ÖÖ·½·¨£ºCreateSQLQuery¡£ÒÔϲ¿·ÖÀý×ÓÔ´×ÔÓÚÍøÂç¡£
ʵÀýÒ»£¨Ô´×ÔÓÚ ......

SQL·ÖÒ³ ÀûÓÃID´óÓÚ¶àÉÙºÍSELECT TOP·ÖÒ³

Óï¾äÐÎʽ£º¡¡ SELECTTOP10*
fromTestTable
WHERE(ID>
¡¡¡¡¡¡¡¡¡¡(SELECTMAX(id)
¡¡¡¡¡¡¡¡from(SELECTTOP20id
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fromTestTable
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ORDERBYid)AST))
ORDERBYID
SELECTTOPÒ³´óС*
fromTestTable
WHERE(ID>
¡¡¡¡¡¡¡¡¡¡(SELECTMAX(id)
¡¡¡¡¡¡¡¡from(SELECTTOPÒ³´óС*Ò³Êýid
¡¡¡¡¡ ......

SQL Server Óï¾ä²éѯÊÖ²á

½¨±í£º
CREATE TABLE  [DB.dbo].tableName
(Stud_id int CONSTRAINT  constraintName1  not null primary key,
 Name nvarchar(5) not null,
 Birthday datetime,
 Gender nchar(1),
 Telcode char(12),
 Zipcode char(6) CONSTRAINT constraintName2 CHECK(zipcode like [ ......

sql³£ÓÃÓï¾ä

ÔÚSQLSERVER£¬¼òµ¥µÄ×éºÏsp_spaceusedºÍsp_MSforeachtableÕâÁ½¸ö´æ´¢¹ý³Ì£¬¿ÉÒÔ·½±ãµÄͳ¼Æ³öÓû§Êý¾Ý±íµÄ´óС£¬°üÀ¨¼Ç¼×ÜÊýºÍ¿Õ¼äÕ¼ÓÃÇé¿ö£¬·Ç³£ÊµÓã¬ÔÚSqlServer2KºÍSqlServer2005Öж¼²âÊÔͨ¹ý¡£
/*
1. exec sp_spaceused '±íÃû'            £¨SQLͳ¼ÆÊý¾Ý£¬´óÁ¿ÊÂÎñ²Ù×÷ºó¿É ......

sql È¥¿Õ¸ñÓëÁ¬½ÓÌØÊâ×Ö·û

ÔÚ·Ö×éÅÅÐò¹ý³ÌÖÐÐèҪн¨ÅÅÐòÁУ¬°´Ìõ¼þ:(ÎïÁÏ·ÖÀà+¿Í»§Ãû³Æ) ½øÐзÖ×é»ã×Ü È»ºó¾Í¸ù¾Ý¸ÃÌõ¼þ½øÐÐÅÅÐò
1.ÐèҪƴ´ÕÁ½ÁÐ ×÷ΪÅÅÐòÁÐ,ÈçÐè¼ÓÈëÌØÊâ×Ö·û.¾Í»á±¨´í.
   ÒòΪ±¾Éí¸Ä×ֶξÍÊÇvarcharÀàÐÍ ÐèÒª½«charÀàÐÍ'_' ת»»³Évarchar
2.Æ´´Õ¹ý³ÌÖÐÓпոñÐèҪȥ¿Õ¸ñ
 e.g£ºselect (trim(ÎïÁÏ·ÖÀà)+to_char( ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ