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

sql server ¶¨ÒåÖ÷¼ü

drop table father;
create table father(
 id int identity(1,1) primary key,
 name varchar(20) not null,
 age int not null
  
)
drop table mother;
create table mother(
 id int identity(1,1),
 name varchar(20) not null,
 age int not null,
 husband int not null
)
alter table mother
  add constraint FK_ID foreign key(husband) references father(id)
Èç¹û ÔÚfatherÖÐûÄܶ¨ÒåÖ÷¼ü£¬
drop table father;
create table father(
 id int identity(1,1),   (䶨Òå primary key)
 name varchar(20) not null,
 age int not null
)
 Ôò»á±¨ÈçÏÂÒì³££º
ÔÚ±»ÒýÓñí 'father' ÖÐûÓÐÓëÍâ¼ü 'FK_ID' µÄÒýÓÃÁеÄÁбíÆ¥ÅäµÄÖ÷¼ü»òºòÑ¡¼ü


Ïà¹ØÎĵµ£º

ÔÚSQL ServerÖÐʹÓÃNewID()·½·¨²úÉúËæ»ú¼¯

ÔÚSQL ServerÖÐʹÓÃNewID()·½·¨²úÉúËæ»ú¼¯
ÀýÈ翼ÊÔϵͳÖеÄËæ»ú³öÌâ
¸Õ¿ªÊ¼Ïëµ½µÄÊÇRandomÀà
µ«ÊÇRandomЧÂÊÓеãµÍ
ºóÀ´Ïëµ½ÁËÔÚÊý¾Ý¿âÀïµÄnewid()
ÓÚÊDzÉÓÃÁËϱ߷½·¨£º
select top 5 * from tablename order by newid()
Ôڴ˱ê¼ÇһϠ......

½«±íÊý¾ÝÉú³ÉSQL½Å±¾µÄ´æ´¢¹ý³Ì

CREATE PROCEDURE dbo.UspOutputData
@tablename sysname
AS
declare @column varchar(1000)
declare @columndata varchar(1000)
declare @sql varchar(4000)
declare @xtype tinyint
declare @name sysname
declare @objectId int
declare @objectname sysname
declare @ident int
set nocount on ......

sql isnullº¯ÊýµÄʹÓÃ


sql isnullº¯ÊýµÄʹÓÃ
ISNULL
ʹÓÃÖ¸¶¨µÄÌæ»»ÖµÌæ»» NULL¡£
Óï·¨
ISNULL ( check_expression , replacement_value )
²ÎÊý
check_expression
½«±»¼ì²éÊÇ·ñΪ NULLµÄ±í´ïʽ¡£check_expression ¿ÉÒÔÊÇÈκÎÀàÐ͵ġ£
replacement_value
ÔÚ check_expression Ϊ NULLʱ½«·µ»ØµÄ±í´ïʽ¡£replacement_value ±ØÐëÓë chec ......

oracle sqlÓï¾äÓÅ»¯»ù´¡

¾¡Á¿ÉÙÓÃIN²Ù×÷·û£¬»ù±¾ÉÏËùÓеÄIN²Ù×÷·û¶¼¿ÉÒÔÓÃEXISTS´úÌæ¡£
²»ÓÃNOT IN²Ù×÷·û£¬¿ÉÒÔÓÃNOT EXISTS»òÕßÍâÁ¬½Ó+Ìæ´ú¡£
OracleÔÚÖ´ÐÐIN×Ó²éѯʱ£¬Ê×ÏÈÖ´ÐÐ×Ó²éѯ£¬½«²éѯ½á¹û·ÅÈëÁÙʱ±íÔÙÖ´ÐÐÖ÷²éѯ¡£¶øEXISTÔòÊÇÊ×Ïȼì²éÖ÷²éѯ£¬È»ºóÔËÐÐ×Ó²éѯֱµ½ÕÒµ½µÚÒ»¸öÆ¥ÅäÏî¡£NOT EXISTS±ÈNOT INЧÂÊÉԸߡ£µ«¾ßÌåÔÚÑ¡ÔñIN»òEXIST² ......

Ñ­Ðò½¥½ø½²½âSQL²éѯÓï¾ä¸ß¼¶Ó¦Óü¼ÇÉ

Ò»¡¢ ¼òµ¥²éѯ
¼òµ¥µÄTransact-SQL²éѯֻ°üÀ¨Ñ¡ÔñÁÐ±í¡¢from×Ó¾äºÍWHERE×Ӿ䡣ËüÃÇ·Ö±ð˵Ã÷Ëù²éѯÁС¢²éѯµÄ
±í»òÊÓͼ¡¢ÒÔ¼°ËÑË÷Ìõ¼þµÈ¡£
ÀýÈ磬ÏÂÃæµÄÓï¾ä²éѯtesttable±íÖÐÐÕÃûΪ“ÕÅÈý”µÄnickname×ֶκÍemail×ֶΡ£
SELECT nickname,email
from testtable
WHERE name='ÕÅÈý'
 
(Ò») Ñ¡Ôñ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ