본문 바로가기
프로그래밍/DBMS

[MSSQL] Create Table

by zoo10 2017. 10. 31.

테이블 생성 템플릿 양식



IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_table>', 'U') IS NOT NULL

  DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>

GO


CREATE TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>

(

<columns_in_primary_key, , c1> <column1_datatype, , int> <column1_nullability,, NOT NULL>, 

<column2_name, sysname, c2> <column2_datatype, , char(10)> <column2_nullability,, NULL>, 

<column3_name, sysname, c3> <column3_datatype, , datetime> <column3_nullability,, NULL>, 

    CONSTRAINT <contraint_name, sysname, PK_sample_table> PRIMARY KEY (<columns_in_primary_key, , c1>)

)

GO