화난코더


The following table summarizes the Connector/J versions available:

Connector/J version Driver Type JDBC version MySQL Server version Status
5.1 4 3.0, 4.0 4.1, 5.0, 5.1, 5.4 Recommended version
5.0 4 3.0 4.1, 5.0 Released version
3.1 4 3.0 4.1, 5.0 Obsolete
3.0 4 3.0 3.x, 4.1 Obsolete


원문보기
Posted by 화난코더

팀에 새로 입사하신 분이 SQL Server object네이밍을 C# 메소드명 이름 짓듯이 생성하여 사용하였더군요.
기존에 개발되어 있는 DB가 아래와 거의 비슷한 일반적으로 업계에서 많이 사용하는 네이밍 룰을 따르고 있는데 보란듯이 다르게 가더군요.
왜 표준을 따르지 않았냐고 했더니 표준이 어디있냐며 본인이 한대로 써보고 좋으면 이렇게 사용하자고 하더군요.
쩝.... 제가 업무에 있어서 보수적이라 그런지 현재 구축되어 있는 룰을 무시하고 작업을 진행하는 것은 안좋아보이는 더군요. 그래서 현재는 DB가 어떤 개발자가 개발했느냐에 따라 서로 다른 컨벤션으로 DB가 적용되어져 있습니다.

구글에서 네이밍룰을 어떻게 적용하고 있는 좀 찾아보다 맘에 드는 내용을 올려 봤습니다.
대부분 저희팀에서 사용하는 룰과 비슷하고 한가지 다른점이 있다면 저희는 SP에 USP_라는 prefix를 붙이는데 아래에는 붙이지를 않네요.

Database Object Naming Rules

원문보기


Summary:

 

Casing

Prefix

Suffix

Alpha Numeric Characters

Notes

Tables

Pascal

 

 

x

Use singular form: Eg User, not Users

Linking Tables

Pascal

 

Link

x

Formed from the Tables they are linking, eg: A Table joining User and Group would be UserGroupLink

Table Columns

Pascal

 

 

x

 

Primary Key

Pascal

PK_

 

x

 

Clustered Index

Pascal

IXC_

 

x

 

Unique Clustered Index

Pascal

IXCU_

 

x

 

Unique Index

Pascal

IXU_

 

x

 

Index

Pascal

IX_

 

x

 

XML Index

Pascal

XML_IX_

 

x

 

XML Columns

Pascal

 

 

x

Use .net Pascal casing, no underscores

Constraints

Pascal

CK_

 

x

 

Default Value

Pascal

DF_

 

x

 

Foreign Keys

Pascal

FK_

 

x

 

Views

Pascal

VW_

 

x

 

Functions

Pascal

FN_

 

x

 

Stored Procedures

Pascal

none

 

x

 

Triggers (after)

Pascal

TRGA_

 

x

 

Triggers (instead)

Pascal

TRGI_

 

x

 

Schemas

  • Use lowercase for schema names.
  • Always alias database objects using the schema name, even if this is the default [dbo] schema
  • This applies to both CREATE statements and when referencing objects in FROM, INSERT or UPDATE statements etc.

Table Names

  • Pascal Case
  • Alpha-numeric
  • Avoid underscore
  • No Prefix
  • Use the Singular Form eg: User, not Users

Linking Table Names

  • Linking Tables should be the name of the two tables it is joining, suffixed with Link. Eg a joining table on User and Group would be UserGroupLink

Column Names

  • Pascal Case
  • Alpha-numeric
  • Avoid underscore
  • No Prefix
  • Format: <TableName(for PK only)><Qualifier><Name>

use the following components in the order below;

    • Table Name: Primary keys only; Tables names are used to prefix all columns in dotted format, so this is not necessarily. The exception is the primary key since this is used in foreign keys.
    • Qualifier: Optional; Description, to clarify the meaning of the field. For example, if a product has two images, this would clarify the field, eg. FrontImage and RearImage
    • Name: Required; This is a database independent “datatype” descriptor which is used to classify the type of data. Below is a common list of standard classifiers. The exception to this is a Boolean. This should be Prefixed with “Is” as this more positively represents the meaning o the value. Flag suffix is considered optional “Flag” or Eg. IsEnabled or IsEnabledFlag

 

Classifier

Description

Suggested SQL Data Type

Address

Street or mailing address data

nvarchar

Age

Chronological age in years

int

Average

Average; consider a computed column

numeric

Amount

Currency amount

money

Code

Non Database Identifier

 

Count

 

 

Data

A field containing extensible data

xml

Date

Calendar date

smalldatetime

Datetime

Date including time

datetime

Day

Day of month (1 - 31)

tinyint

Description

Brief narrative description

nvarchar(MAX)

Duration

Length of time, eg minutes

int

ID

Unique identifier for something

int

Image

A graphic image, such as a bitmap

varbinary(MAX)

Flag

Not Required: Flag indicates a boolean indicator, where the Qualifier verb does not make it clear it is a verb. Examples of a Qualifier are: Is, Has, Uses. Eg IsEnabled

bit

Month

Month of year

 

Name

Formal name

nvarchar

Number

 

 

Percent

Number expressed as a percent

 

Quantity

A number of things

any numerical

Rate

Number expressed as a rate

any numerical

Ratio

A proportion, or expression of relationship in quantity, size, amount, etc. between two things

any numerical

Sequence

A numeric order field

int

Text

Freeform textual information

nvarchar(MAX)

Time

Time of day

smalldatetime

Title

Formal name of something

nvarchar

Version

Timestamp

timestamp

Weight

Weight measurement

any numerical

XML

A field containing xml data

xml

Year

Calendar year or julian year number

 

Stored Procedure Names

·         Use PascalCase

  • Naming Format: use the following components in the order below;
    • Object: Required; usually the table or combinations of tables it is affecting, followed by underscore.
    • Action: Required; eg Save, Load, Get, Set, SetSingle, Search, Delete
    • Qualifier: Optional; additional descriptive words which help to clarify the specific meaning of the stored procedure
    • Return Type: Optional; Indicates the type of data return
  • Example Stored Procedure Names:
    • AuthorSave
    • AuthorLoad
    • AuthorLoadByAuthorID
    • AuthorLoadByName
  • Do not:
    • Use special characters.
    • Use stored procedure group numbers (e.g. myProc;1).
    • prefix names with “sp_” as those are reserved for procedures shipped by SQL Server.

User Defined Functions (UDF) Names

·         Use PascalCase

  • Naming Format: use the following components in the order below;
    • Prefix: Required; “FN_”
    • Object: Required; usually the table or combinations of tables it is affecting, followed by underscore.
    • Action: Required; eg Get, Set, SetSingle, Search, Delete
    • Qualifier: Optional; additional descriptive words which help to clarify the specific meaning of the stored procedure
    • Return Type: Optional; Indicates the type of data return
  • Example Function Names:
    • FN_AuthorGetID
  • Often stored procedures will replicate (wrap) a user defined function. In this case the names should be identical with the exception of the additional prefix on a UDF.
  • Note, udfs cannot have any “effects” so cannot modify data.

Parameters - Stored Procedure/UDFs

  • Use PascalCase
  • Eg: @PageID

Variables - Stored Procedure/UDFs

  • Use camelCase
  • Eg: @pageID

Cursor Names

·         Use PascalCase, except for prefix

  • Naming Format: use the following components in the order below;
    • Prefix: Required; prefix with “CURSOR_”
    • Object: Required; usually the table being iterated over.
  • Note: Avoid the use of cursors where possible. Instead use a while loop

Updatable View Names

For Views which are updatable, act as if they are a table.

This holds true for Updatable Partitioned Views.

 

·         Use PascalCase, except for prefix

  • Naming Format: use the following components in the order below;
    • Prefix: Required; prefix with “VW_”
    • Object: Required; usually related to the table(s) affected by the view
    • Qualifier: Optional; additional descriptive words which help to clarify the purpose of the view.

Non Updatable View Names

 

For Views which provide a view on the data which makes them read only.

 

·         Use PascalCase, except for prefix

  • Naming Format: use the following components in the order below;
    • Prefix: Required; prefix with “VW_”
    • Object: Required; usually the concatenation of tables in the view
    • Qualifier: Optional; additional descriptive words which help to clarify the purpose of the view.

Trigger Names

·         Use PascalCase, except for prefix

  • Naming Format: use the following components in the order below;
    • Prefix: Required; prefix with “TRG”
    • Type: Required; depending on type of trigger, after or instead of. prefix with “A_” or “I_”
    • Object: Required; usually the table being iterated over.
    • Actions covered: Required; composite key of actions, “Upd”, “Ins”, “Del”

·         Example Trigger Names:

o    TRGA_CustomerInsUpdDe

o    TRGA_ProductDel

o    TRGI_AuthorUpd

Index Names

Index names are unique within a table so it isn’t necessary to include the tablename in the index. When looking at execution plans it is helpful to have a hint about the columns being indexed

  • Naming Format: use the following components in the order below;
    • Prefix: Required; prefix with “IX”
    • Clustered: Required; if Clustered Index include “C”
    • Unique: Required; if Unique Index include “U”
    • Column Names: Required; Include the list of columns indexed, using underscores between the column names. For an index that covers all columns in the table, use the word All.

·         Example Index Names:

o    IXCU_AuthorID   (clustered unique)

o    IXU_AuthorID (unique)

o    IX_AuthorID_AuthorName (composite index)

o    IXC_AuthorID  (clustered not unique)

Primary Key Names

  • Naming Format: use the following components in the order below;
    • Prefix: Required; prefix primary key with “PK_”
    • TableName: Required; Table name of table being keyed
  • Examples:

o    PK_Customer

Foreign Key Names

  • Naming Format: use the following components in the order below;
    • Prefix: Required; prefix foreign key with “FK_”
    • Reference Table Name(s): Required; Table name of table in the join, for which a unique index is on column(s) being linked. Where both have a unique index, such as linking key, order is optional
    • Foreign Table Name(s): Required; Table name of table in the join, for there is not a unique index on the column(s) being linked.
  • Example foreign key names:
    • FK_Country_Customer
    • FK_Customer_Sales

Default Value Constraint Names

  • Naming Format: use the following components in the order below;
    • Prefix: Required; prefix default value constraint with “DF_”
    • TableName: Required; Table name
    • ColumnName: Required; Column name
  • Example foreign key names:
    • DF_Author_Gender

Check Constraint Names

  • Naming Format: use the following components in the order below;
    • Prefix: Required; prefix check constraint with “CK_”
    • TableName: Required; Table name
    • Integer: Required; Where the integer id is used to distinguish the check constraint from other check constraints on the same table.
    •  
  • Example foreign key names:
    • CK_Author1

Abbreviation Standards

Avoid abbreviations, unless absolutely necessary, due to length restrictions

Database Collation

  • For new databases use: Latin1_General_CI_AS
  • For migrated databases, keep with the same collation as specified in the source database – often this will be: SQL_Latin1_General_Cp1_CI_AS as this is the default for a database migrated from SQL 7.0 to SQL2000
  • Ensure all columns use this option. They will if they are created in the database using, the correct collation.

Posted by 화난코더

sp_spaceused 프로시져로 테이블 사이즈를 확인 할 수 있습니다.

테이블 용량 확인 프로시져


Posted by 화난코더
MS-SQL 2000으로 서비스되는 DB를 2005로 마이그레이션 작업을 진행하였다.
Application수정을 최소화하기 위해 DBMS를 80 호환성 모드로 동작시켰다.
MS SQL 2000버전에서 2005버전으로 마이그레이션시 고려해야할 사항을 올려본다.

영향도

수정

호환성 레벨

항목

증상

처리

높음

클라이언트 / 서버

90

특정 OUTER JOIN 구문 수행불가

*= ,=* (LEFT OUTER , RIGHT OUTER)

80에서는 가능하므로 레벨 전환
90에서는 ANSI SQL에 맞게 쿼리 수정

중간

클라이언트 / 서버

90

ORDER BY

ORDER BY 절의 열별칭에 접두어로 테이블 별칭을 붙일 수 없음

80에서는 가능
쿼리 수정BOL 예제 참고

중간

클라이언트 / 서버

90

ORDER BY

ORDER BY 절에서 정수가 아닌 상수는 허용되지 않음

80에서는 가능
쿼리 수정 BOL 예제 참고

높음

클라이언트 / 서버

공통

TOP 구문

TOP 구문 수행시 정렬되지 않은 데이터 출력

TOP을 사용할 때 명시적으로 ORDER BY 수행하게 수정할 것

중간

클라이언트 / 서버

90

힌트 사용

WITH 테이블힌트

80에서는 가능
90에서는 WITH 명시하고 힌트사용

높음

서버

공통

DTS 패키지

DTS 도구가 없음 (Legacy 구성요소로 저장되어 수행은 가능하며 디자인 변경은 따로 Featurepack을 설치해야함)

장기적으로 유지보수를 위해 SSIS 이전 필요
Legacy 구성요소에서 수행하거나
SSIS의 DTS 패키지 실행작업으로 우선 수행
 

Posted by 화난코더