关于数据库命名规范的问题

cheng_feng001 2008-03-03 02:43:37
今天看了一些命名规范方面的资料,有以下几个问题:
1.好多都提到数据表的命名严禁采用大小写混用的命名方式,为什么?我一直都用Pascal规则命名数据表,这有什么错呢?
2.为什么都建议采用全部小写的方式命名数据表和字段名?我觉得Pascal命名看起来舒服些。
3.不允许给存储过程加上sp_前缀(sp_前缀是系统存储过程)。我看SQL Server里系统存储过程的前缀不是dt_嘛,什么时候成sp_了!

各位数据库都是怎样命名的?交流一下啊。。
...全文
79 点赞 收藏 10
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
liuchuxin 2009-09-21
关注~~
回复
yimeng123 2008-03-03
重金诚聘C++
http://topic.csdn.net/u/20080227/14/8bce0844-bd15-42f0-9cda-a343d5d6601b.html?seed=2111206245
回复
dawugui 2008-03-03
将来的关键字
下列关键字可能会在将来的 SQL Server 版本中保留使用,作为将来要实现的新功能。注意,不要使用这些关键字作为标识符。

ABSOLUTE
FOUND
PREPARE

ACTION
FREE
PRESERVE

ADMIN
FULLTEXTTABLE
PRIOR

AFTER
GENERAL
PRIVILEGES

AGGREGATE
GET
READS

ALIAS
GLOBAL
REAL

ALLOCATE
GO
RECURSIVE

ARE
GROUPING
REF

ARRAY
HOST
REFERENCING

ASSERTION
HOUR
RELATIVE

AT
IGNORE
RESULT

BEFORE
IMMEDIATE
RETURNS

BINARY
INDICATOR
ROLE

BIT
INITIALIZE
ROLLUP

BLOB
INITIALLY
ROUTINE

BOOLEAN
INOUT
ROW

BOTH
INPUT
ROWS

BREADTH
INT
SAVEPOINT

CALL
INTEGER
SCROLL

CASCADED
INTERVAL
SCOPE

CAST
ISOLATION
SEARCH

CATALOG
ITERATE
SECOND

CHAR
LANGUAGE
SECTION

CHARACTER
LARGE
SEQUENCE

CLASS
LAST
SESSION

CLOB
LATERAL
SETS

COLLATION
LEADING
SIZE

COMPLETION
LESS
SMALLINT

CONNECT
LEVEL
SPACE

CONNECTION
LIMIT
SPECIFIC

CONSTRAINTS
LOCAL
SPECIFICTYPE

CONSTRUCTOR
LOCALTIME
SQL

CORRESPONDING
LOCALTIMESTAMP
SQLEXCEPTION

CUBE
LOCATOR
SQLSTATE

CURRENT_PATH
MAP
SQLWARNING

CURRENT_ROLE
MATCH
START

CYCLE
MINUTE
STATE

DATA
MODIFIES
STATEMENT

DATE
MODIFY
STATIC

DAY
MODULE
STRUCTURE

DEC
MONTH
TEMPORARY

DECIMAL
NAMES
TERMINATE

DEFERRABLE
NATURAL
THAN

DEFERRED
NCHAR
TIME

DEPTH
NCLOB
TIMESTAMP

DEREF
NEW
TIMEZONE_HOUR

DESCRIBE
NEXT
TIMEZONE_MINUTE

DESCRIPTOR
NO
TRAILING

DESTROY
NONE
TRANSLATION

DESTRUCTOR
NUMERIC
TREAT

DETERMINISTIC
OBJECT
TRUE

DICTIONARY
OLD
UNDER

DIAGNOSTICS
ONLY
UNKNOWN

DISCONNECT
OPERATION
UNNEST

DOMAIN
ORDINALITY
USAGE

DYNAMIC
OUT
USING

EACH
OUTPUT
VALUE

END-EXEC
PAD
VARCHAR

EQUALS
PARAMETER
VARIABLE

EVERY
PARAMETERS
WHENEVER

EXCEPTION
PARTIAL
WITHOUT

EXTERNAL
PATH
WORK

FALSE
POSTFIX
WRITE

FIRST
PREFIX
YEAR

FLOAT
PREORDER
ZONE

回复
dawugui 2008-03-03
ODBC 保留关键字
保留了下列关键字以用于 ODBC 函数调用。这些关键字根本不约束 SQL 语法;然而,为确保与支持核心 SQL 语法的驱动程序兼容,应用程序应避免使用这些关键字。

下面是当前的 ODBC 保留关键字列表。

ABSOLUTE
EXEC
OVERLAPS

ACTION
EXECUTE
PAD

ADA
EXISTS
PARTIAL

ADD
EXTERNAL
PASCAL

ALL
EXTRACT
POSITION

ALLOCATE
FALSE
PRECISION

ALTER
FETCH
PREPARE

AND
FIRST
PRESERVE

ANY
FLOAT
PRIMARY

ARE
FOR
PRIOR

AS
FOREIGN
PRIVILEGES

ASC
FORTRAN
PROCEDURE

ASSERTION
FOUND
PUBLIC

AT
FROM
READ

AUTHORIZATION
FULL
REAL

AVG
GET
REFERENCES

BEGIN
GLOBAL
RELATIVE

BETWEEN
GO
RESTRICT

BIT
GOTO
REVOKE

BIT_LENGTH
GRANT
RIGHT

BOTH
GROUP
ROLLBACK

BY
HAVING
ROWS

CASCADE
HOUR
SCHEMA

CASCADED
IDENTITY
SCROLL

CASE
IMMEDIATE
SECOND

CAST
IN
SECTION

CATALOG
INCLUDE
SELECT

CHAR
INDEX
SESSION

CHAR_LENGTH
INDICATOR
SESSION_USER

CHARACTER
INITIALLY
SET

CHARACTER_LENGTH
INNER
SIZE

CHECK
INPUT
SMALLINT

CLOSE
INSENSITIVE
SOME

COALESCE
INSERT
SPACE

COLLATE
INT
SQL

COLLATION
INTEGER
SQLCA

COLUMN
INTERSECT
SQLCODE

COMMIT
INTERVAL
SQLERROR

CONNECT
INTO
SQLSTATE

CONNECTION
IS
SQLWARNING

CONSTRAINT
ISOLATION
SUBSTRING

CONSTRAINTS
JOIN
SUM

CONTINUE
KEY
SYSTEM_USER

CONVERT
LANGUAGE
TABLE

CORRESPONDING
LAST
TEMPORARY

COUNT
LEADING
THEN

CREATE
LEFT
TIME

CROSS
LEVEL
TIMESTAMP

CURRENT
LIKE
TIMEZONE_HOUR

CURRENT_DATE
LOCAL
TIMEZONE_MINUTE

CURRENT_TIME
LOWER
TO

CURRENT_TIMESTAMP
MATCH
TRAILING

CURRENT_USER
MAX
TRANSACTION

CURSOR
MIN
TRANSLATE

DATE
MINUTE
TRANSLATION

DAY
MODULE
TRIM

DEALLOCATE
MONTH
TRUE

DEC
NAMES
UNION

DECIMAL
NATIONAL
UNIQUE

DECLARE
NATURAL
UNKNOWN

DEFAULT
NCHAR
UPDATE

DEFERRABLE
NEXT
UPPER

DEFERRED
NO
USAGE

DELETE
NONE
USER

DESC
NOT
USING

DESCRIBE
NULL
VALUE

DESCRIPTOR
NULLIF
VALUES

DIAGNOSTICS
NUMERIC
VARCHAR

DISCONNECT
OCTET_LENGTH
VARYING

DISTINCT
OF
VIEW

DOMAIN
ON
WHEN

DOUBLE
ONLY
WHENEVER

DROP
OPEN
WHERE

ELSE
OPTION
WITH

END
OR
WORK

END-EXEC
ORDER
WRITE

ESCAPE
OUTER
YEAR

EXCEPT
OUTPUT
ZONE

EXCEPTION


回复
dawugui 2008-03-03
以上为2000
以下为2005

下表列出了 SQL Server 保留关键字。

ADD
EXCEPT
PERCENT

ALL
EXEC
PLAN

ALTER
EXECUTE
PRECISION

AND
EXISTS
PRIMARY

ANY
EXIT
PRINT

AS
FETCH
PROC

ASC
FILE
PROCEDURE

AUTHORIZATION
FILLFACTOR
PUBLIC

BACKUP
FOR
RAISERROR

BEGIN
FOREIGN
READ

BETWEEN
FREETEXT
READTEXT

BREAK
FREETEXTTABLE
RECONFIGURE

BROWSE
FROM
REFERENCES

BULK
FULL
REPLICATION

BY
FUNCTION
RESTORE

CASCADE
GOTO
RESTRICT

CASE
GRANT
RETURN

CHECK
GROUP
REVOKE

CHECKPOINT
HAVING
RIGHT

CLOSE
HOLDLOCK
ROLLBACK

CLUSTERED
IDENTITY
ROWCOUNT

COALESCE
IDENTITY_INSERT
ROWGUIDCOL

COLLATE
IDENTITYCOL
RULE

COLUMN
IF
SAVE

COMMIT
IN
SCHEMA

COMPUTE
INDEX
SELECT

CONSTRAINT
INNER
SESSION_USER

CONTAINS
INSERT
SET

CONTAINSTABLE
INTERSECT
SETUSER

CONTINUE
INTO
SHUTDOWN

CONVERT
IS
SOME

CREATE
JOIN
STATISTICS

CROSS
KEY
SYSTEM_USER

CURRENT
KILL
TABLE

CURRENT_DATE
LEFT
TEXTSIZE

CURRENT_TIME
LIKE
THEN

CURRENT_TIMESTAMP
LINENO
TO

CURRENT_USER
LOAD
TOP

CURSOR
NATIONAL
TRAN

DATABASE
NOCHECK
TRANSACTION

DBCC
NONCLUSTERED
TRIGGER

DEALLOCATE
NOT
TRUNCATE

DECLARE
NULL
TSEQUAL

DEFAULT
NULLIF
UNION

DELETE
OF
UNIQUE

DENY
OFF
UPDATE

DESC
OFFSETS
UPDATETEXT

DISK
ON
USE

DISTINCT
OPEN
USER

DISTRIBUTED
OPENDATASOURCE
VALUES

DOUBLE
OPENQUERY
VARYING

DROP
OPENROWSET
VIEW

DUMMY
OPENXML
WAITFOR

DUMP
OPTION
WHEN

ELSE
OR
WHERE

END
ORDER
WHILE

ERRLVL
OUTER
WITH

ESCAPE
OVER
WRITETEXT

回复
dawugui 2008-03-03
将来的关键字
以下关键字可能会保留在将来的 SQL Server 版本中,作为将来要实现的新特性。注意,不要使用这些关键字作为标识符。

ABSOLUTE FOUND PRESERVE
ACTION FREE PRIOR
ADMIN GENERAL PRIVILEGES
AFTER GET READS
AGGREGATE GLOBAL REAL
ALIAS GO RECURSIVE
ALLOCATE GROUPING REF
ARE HOST REFERENCING
ARRAY HOUR RELATIVE
ASSERTION IGNORE RESULT
AT IMMEDIATE RETURNS
BEFORE INDICATOR ROLE
BINARY INITIALIZE ROLLUP
BIT INITIALLY ROUTINE
BLOB INOUT ROW
BOOLEAN INPUT ROWS
BOTH INT SAVEPOINT
BREADTH INTEGER SCROLL
CALL INTERVAL SCOPE
CASCADED ISOLATION SEARCH
CAST ITERATE SECOND
CATALOG LANGUAGE SECTION
CHAR LARGE SEQUENCE
CHARACTER LAST SESSION
CLASS LATERAL SETS
CLOB LEADING SIZE
COLLATION LESS SMALLINT
COMPLETION LEVEL SPACE
CONNECT LIMIT SPECIFIC
CONNECTION LOCAL SPECIFICTYPE
CONSTRAINTS LOCALTIME SQL
CONSTRUCTOR LOCALTIMESTAMP SQLEXCEPTION
CORRESPONDING LOCATOR SQLSTATE
CUBE MAP SQLWARNING
CURRENT_PATH MATCH START
CURRENT_ROLE MINUTE STATE
CYCLE MODIFIES STATEMENT
DATA MODIFY STATIC
DATE MODULE STRUCTURE
DAY MONTH TEMPORARY
DEC NAMES TERMINATE
DECIMAL NATURAL THAN
DEFERRABLE NCHAR TIME
DEFERRED NCLOB TIMESTAMP
DEPTH NEW TIMEZONE_HOUR
DEREF NEXT TIMEZONE_MINUTE
DESCRIBE NO TRAILING
DESCRIPTOR NONE TRANSLATION
DESTROY NUMERIC TREAT
DESTRUCTOR OBJECT TRUE
DETERMINISTIC OLD UNDER
DICTIONARY ONLY UNKNOWN
DIAGNOSTICS OPERATION UNNEST
DISCONNECT ORDINALITY USAGE
DOMAIN OUT USING
DYNAMIC OUTPUT VALUE
EACH PAD VARCHAR
END-EXEC PARAMETER VARIABLE
EQUALS PARAMETERS WHENEVER
EVERY PARTIAL WITHOUT
EXCEPTION PATH WORK
EXTERNAL POSTFIX WRITE
FLASE PREFIX YEAR
FIRST PREORDER ZONE
FLOAT PREPARE
回复
dawugui 2008-03-03
ODBC 保留关键字
保留了下列关键字用于 ODBC 函数调用。这些关键字根本不约束 SQL 语法;然而,为确保与支持核心 SQL 语法的驱动程序兼容,应用程序应避免使用这些关键字。

下面是当前的 ODBC 保留关键字列表。有关更多信息,请参见《Microsoft ODBC 3.0 程序员参考》,第 2 卷,附录 C。

ABSOLUTE EXEC OVERLAPS
ACTION EXECUTE PAD
ADA EXISTS PARTIAL
ADD EXTERNAL PASCAL
ALL EXTRACT POSITION
ALLOCATE FALSE PRECISION
ALTER FETCH PREPARE
AND FIRST PRESERVE
ANY FLOAT PRIMARY
ARE FOR PRIOR
AS FOREIGN PRIVILEGES
ASC FORTRAN PROCEDURE
ASSERTION FOUND PUBLIC
AT FROM READ
AUTHORIZATION FULL REAL
AVG GET REFERENCES
BEGIN GLOBAL RELATIVE
BETWEEN GO RESTRICT
BIT GOTO REVOKE
BIT_LENGTH GRANT RIGHT
BOTH GROUP ROLLBACK
BY HAVING ROWS
CASCADE HOUR SCHEMA
CASCADED IDENTITY SCROLL
CASE IMMEDIATE SECOND
CAST IN SECTION
CATALOG INCLUDE SELECT
CHAR INDEX SESSION
CHAR_LENGTH INDICATOR SESSION_USER
CHARACTER INITIALLY SET
CHARACTER_LENGTH INNER SIZE
CHECK INPUT SMALLINT
CLOSE INSENSITIVE SOME
COALESCE INSERT SPACE
COLLATE INT SQL
COLLATION INTEGER SQLCA
COLUMN INTERSECT SQLCODE
COMMIT INTERVAL SQLERROR
CONNECT INTO SQLSTATE
CONNECTION IS SQLWARNING
CONSTRAINT ISOLATION SUBSTRING
CONSTRAINTS JOIN SUM
CONTINUE KEY SYSTEM_USER
CONVERT LANGUAGE TABLE
CORRESPONDING LAST TEMPORARY
COUNT LEADING THEN
CREATE LEFT TIME
CROSS LEVEL TIMESTAMP
CURRENT LIKE TIMEZONE_HOUR
CURRENT_DATE LOCAL TIMEZONE_MINUTE
CURRENT_TIME LOWER TO
CURRENT_TIMESTAMP MATCH TRAILING
CURRENT_USER MAX TRANSACTION
CURSOR MIN TRANSLATE
DATE MINUTE TRANSLATION
DAY MODULE TRIM
DEALLOCATE MONTH TRUE
DEC NAMES UNION
DECIMAL NATIONAL UNIQUE
DECLARE NATURAL UNKNOWN
DEFAULT NCHAR UPDATE
DEFERRABLE NEXT UPPER
DEFERRED NO USAGE
DELETE NONE USER
DESC NOT USING
DESCRIBE NULL VALUE
DESCRIPTOR NULLIF VALUES
DIAGNOSTICS NUMERIC VARCHAR
DISCONNECT OCTET_LENGTH VARYING
DISTINCT OF VIEW
DOMAIN ON WHEN
DOUBLE ONLY WHENEVER
DROP OPEN WHERE
ELSE OPTION WITH
END OR WORK
END-EXEC ORDER WRITE
ESCAPE OUTER YEAR
EXCEPT OUTPUT ZONE
EXCEPTION
回复
dawugui 2008-03-03
下表列出了 SQL Server 的保留关键字。

ADD EXCEPT PERCENT
ALL EXEC PLAN
ALTER EXECUTE PRECISION
AND EXISTS PRIMARY
ANY EXIT PRINT
AS FETCH PROC
ASC FILE PROCEDURE
AUTHORIZATION FILLFACTOR PUBLIC
BACKUP FOR RAISERROR
BEGIN FOREIGN READ
BETWEEN FREETEXT READTEXT
BREAK FREETEXTTABLE RECONFIGURE
BROWSE FROM REFERENCES
BULK FULL REPLICATION
BY FUNCTION RESTORE
CASCADE GOTO RESTRICT
CASE GRANT RETURN
CHECK GROUP REVOKE
CHECKPOINT HAVING RIGHT
CLOSE HOLDLOCK ROLLBACK
CLUSTERED IDENTITY ROWCOUNT
COALESCE IDENTITY_INSERT ROWGUIDCOL
COLLATE IDENTITYCOL RULE
COLUMN IF SAVE
COMMIT IN SCHEMA
COMPUTE INDEX SELECT
CONSTRAINT INNER SESSION_USER
CONTAINS INSERT SET
CONTAINSTABLE INTERSECT SETUSER
CONTINUE INTO SHUTDOWN
CONVERT IS SOME
CREATE JOIN STATISTICS
CROSS KEY SYSTEM_USER
CURRENT KILL TABLE
CURRENT_DATE LEFT TEXTSIZE
CURRENT_TIME LIKE THEN
CURRENT_TIMESTAMP LINENO TO
CURRENT_USER LOAD TOP
CURSOR NATIONAL TRAN
DATABASE NOCHECK TRANSACTION
DBCC NONCLUSTERED TRIGGER
DEALLOCATE NOT TRUNCATE
DECLARE NULL TSEQUAL
DEFAULT NULLIF UNION
DELETE OF UNIQUE
DENY OFF UPDATE
DESC OFFSETS UPDATETEXT
DISK ON USE
DISTINCT OPEN USER
DISTRIBUTED OPENDATASOURCE VALUES
DOUBLE OPENQUERY VARYING
DROP OPENROWSET VIEW
DUMMY OPENXML WAITFOR
DUMP OPTION WHEN
ELSE OR WHERE
END ORDER WHILE
ERRLVL OUTER WITH
ESCAPE OVER WRITETEXT
回复
cheng_feng001 2008-03-03
不允许使用保留字,那我有个字段名为name,不合法还是不建议采用?
回复
dawugui 2008-03-03
1,名称的长度为1-128位
2,名称的第一个字符必须是一个字母或者"_","@","#"中的任意一个.
3,如果是2005,可以使用中文名称
4,名称中不能有空格,不允许使用保留字.
回复
相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2008-03-03 02:43
社区公告
暂无公告