SQL Table
Table-Naming Standards
Table-naming standards, as well as any standard within a business, are critical to
maintaining control. After studying the tables and data in the previous sections, you
probably noticed that each table’s suffix is _TBL. This is a naming standard selected
for use, such as what’s been used at various client sites. The _TBL simply tells you
that the object is a table; there are many different types of objects in a relational
database. For example, you will see that the suffix _INX is used to identify indexes
on tables in later hours. Naming standards exist almost exclusively for overall
organization and assist immensely in the administration of any relational database.
Remember, the use of a suffix is not mandatory when naming database objects.
Ïà¹ØÎĵµ£º
ÔÚ¹«¹²ÐÂÎÅ×éÖУ¬Ò»¸ö¾³£³öÏÖµÄÎÊÌâÊÇ“ÔõÑù²ÅÄܸù¾Ý´«µÝ¸ø´æ´¢¹ý³ÌµÄ²ÎÊý·µ»ØÒ»¸öÅÅÐòµÄÊä³ö£¿”¡£ÔÚһЩ¸ßˮƽר¼ÒµÄ°ïÖú֮ϣ¬ÎÒÕûÀí³öÁËÕâ¸öÎÊÌâµÄ¼¸ÖÖ½â¾ö·½°¸¡£
Ò»¡¢ÓÃIF...ELSEÖ´ÐÐÔ¤ÏȱàдºÃµÄ²éѯ
¡¡¡¡¶ÔÓÚ´ó¶àÊýÈËÀ´Ëµ£¬Ê×ÏÈÏëµ½µÄ×ö·¨Ò²ÐíÊÇ£ºÍ¨¹ýIF...ELSEÓï¾ä£¬Ö´Ðм¸¸öÔ¤ÏȱàдºÃµÄ²éѯÖеÄÒ» ......
--´Ë´¦Ê¹ÓÃpubs¿â
declare @myname varchar(50)
declare @fname varchar(20)
declare @lname varchar(20)
declare my_cursor cursor for
select fname,lname from employee order by emp_id
open my_cursor
fetch next from my_cursor into @fname,@lname
while @@fetch_status=0
begin
set @ ......
±àдһ¸ö´¢´æ¹ý³Ìusp_GetSortedShippers£¬Ëü½ÓÊÕNorthwindÊý¾Ý¿âÖÐShippers±íµÄÒ»¸öÁÐÃû³Æ×÷ΪÆäÖÐÒ»¸öÊäÈ루@colname£©£¬²¢´Ó¸Ã±í·µ»Ø°´ÊäÈëµÄÁÐÃûÅÅÐòµÄÐС£ÁíÒ»¸öÊäÈ루@sortdir£©±íʾÅÅÐòµÄ·½Ïò,‘A’±íʾ°´Éý˳ÅÅÐò,‘D’±íʾ°´½µÐòÅÅÐò¡£±àд¸Ã´æ´¢¹ý³ÌʱҪעÒâËüµÄÐÔÄÜ£¬¼´£¬¾¡¿ÉÄܵÄʹÓÃË÷Òý£¨ ......
Ê×ÏȾÍÊÇÒª×Ô¼º±àдһ¶Î´úÂ룬´æÎª.stx
Îļþ£¨ÀýÈçsql.stx£©£¬È»ºóÔÚeditplusµÄ²Ëµ¥À¸Tools->Configure User
Tools->Files->Setting &syntax,µãadd°´Å¥£¬ÔÚdescriptionÀ¸Î»ÌîÉÏsql,file
ExtensionsÀ¸Î»Ò²ÌîÉÏsql,Èç¹ûÓжà¸öÀ©Õ¹Ãû£¬Ö®¼äÓÓ£»”¸ô¿ª£¨ÀýÈ磺sql;db2£©,È»ºóÔÚsyntax
fileÀ¸Î»ÌîÉ ......
֮ǰÓÐÒ»¸öSQLServerµÄ·ÖÒ³´æ´¢¹ý³Ì µ«ÊÇÐÔÄܲ»ÊÇÊ®·ÖÀíÏë
ÓÖÕÒÁËÒ»¸ö
--SQL2005·ÖÒ³´æ´¢¹ý³Ì
/**
if exists(select * from sysobjects where name='fenye')
drop proc fenye
**/
CREATE procedure fenye
@tableName nvarchar(200) ,
@pageSize int,
@curPage int ,
......