程序的魔法

  :: 首页 :: 博问 :: 闪存 :: :: 联系 :: :: 管理 ::

SQL Server中变量的缩写   

SQL Server中,我们经常需要给一些变量起名字,但是怎么样起名字才比较合适呢,下面就是一些类型的变量推荐的起名字方法。

数据类型的前缀

数据类型

前缀

例子

Char

chr

@chrFirstName

Varchar

chv

@ chvActivity

nchar

chrn

@ chrnLastName

nvarchar

chvn

@ chvnLastName

Text

txt

@ txtNote

ntext

txtn

@ txtnComment

datatime

dtm

@ dtmTargetDate

smalldatatime

dts

@ dtsCompletionDate

tinyint

iny

@ inyActivityID

smallint

ins

@ insEquipmentTypeID

integer

int

@ intCount

bigint

inb

@ inbCount

Numeric/decimal

dec

@ decProfit

real

rea

@ reaVelocity

float

flt

@ fltLength

smallmoney

mns

@ mnsCost

money

mny

@ mnyPrice

binary

bin

@ binPath

varbinary

biv

@ bivContract

image

img

@ imgLogo

bit

bit

@ bitOperational

timestamp

tsp

@ tspCurrent

uniqueidentifier

guid

@ guidOrderId

Sql_variant

var

@ varPrice

cursor

cur

@ curInventory

table

tbl

@ tblLease

 

2 数据库对象前缀

数据库对象

前缀

例子

Table

无前缀

Activity

Column

无前缀

ActivityId

View

v

vActivity

Stored Procedure

pr

prComleteOrder

Trigger

pr

prOrder_IU

Default

df

dfToday

Rule

rul

rulCheckZip

Index

ix

ixLastName

Primary Key

pk

pkContractId

Foreigh Key

fk

fkOrderOrderType

User-defined data type

udt

udtPhone

User-defined functions

fn

fnDueDates

 

 

上面是一些推荐的系统变量以及数据对象的缩写方式,如果你有更好的,当然你完全可以不按照这些命名规则而自创 一套新的命名规则,但是在一般情况下,还是建议您采用这种方式,因为这是经过多年考验的命名约定。

 

 

 

 

 

 

 

 

 

 

 

posted on 2005-07-09 21:55  BlueMagic  阅读(622)  评论(0编辑  收藏  举报