SQL数据表操作命令备忘
CREATE TABLE [database_name.[owner].| owner.] table_name ( {<column_definition> | column_name AS computed_column_expression |<table_constraint>} [,...n] ) [ON {filegroup | DEFAULT} ] [TEXTIMAGE_ON {filegroup | DEFAULT} ]<column_definition> ::= { column_name data_type }[ [ DEFAULT constant_expression ] | [ IDENTITY [(seed, increment ) [NOT FOR REPLICATION] ] ] ][ ROWGUIDCOL ][ COLLATE < collation_name > ][ <column_constraint>] [ ...n]
创建数据表示例
if exists (select * from dbo.sysobjects where id=object_id(N'[dbo].[products3]') and OBJECTPROPERTY(id,N'IsUserTable')=1)drop table [dbo].[products3]
create table mydb.dbo.products3 (p_id char(8) not null,p_name char(10) not null ,price money default 0.01 ,quantity smallint null ,constraint pk_p_id primary key (p_id, p_name)) on [primary]