如何用SQL语句来建表?

时间:2010-06-13 14:38:00 

如何用SQL 建表?


    如下:

CREATE TABLE statement                                                          
                                                                                  
  CREATE TABLE [<database>.[<owner>].]<table_name>                              
                                                                            
      {<col_name> <column_properties> [<constraint> [<constraint>                
            [... <constraint>]]]                                                  
      | [[,] <constraint>]}                                                      
            [[,] {<next_col_name> |                                                
            <next_constraint>}...]                                                
                                                                                  
  [ON <segment_name>]                                                              
                                                                                  
  <column_properties> =                                                            
      <datatype> [NULL | NOT NULL | IDENTITY[(<seed>, <increment>)]]              
  <constraint> =                                                                  
    For a PRIMARY KEY constraint:                                                  
      [CONSTRAINT <constraint_name>]                                              
            PRIMARY KEY [CLUSTERED | NONCLUSTERED]                                
                (<col_name> [, <col_name2> [..., <col_name16>]])                  
                [ON <segment_name>]                                              
    For a UNIQUE constraint:                                                      
      [CONSTRAINT <constraint_name>]                                              
            UNIQUE [CLUSTERED | NONCLUSTERED]                                      
                (<col_name> [, <col_name2> [..., <col_name16>]])                  
                [ON <segment_name>]                                              
    For a FOREIGN KEY constraint:                                                  
      [CONSTRAINT <constraint_name>]                                              
            [FOREIGN KEY (<col_name> [, <col_name2>                                
                [..., <col_name16> ]])]                                          
                REFERENCES [<owner>.]<ref_table> [(<ref_col>                      
                [, <ref_col2> [..., <ref_col16>]])]                              
    For a DEFAULT constraint:                                                      
      [CONSTRAINT <constraint_name>]                                              
            DEFAULT {<constant_expression> | <niladic-function> | NULL}            
                [FOR <col_name>]                                                  
    For a CHECK constraint(s):                                                    
      [CONSTRAINT <constraint_name>]                                              
            CHECK [NOT FOR REPLICATION] (<expression>)                           

标签:sql,表,数据库
0
投稿

猜你喜欢

  • 图片滤镜效果[IE Only]

    2009-06-14 19:49:00
  • SQL Server 2005常见问题浅析

    2009-03-16 14:06:00
  • 批量替换sqlserver数据库挂马字段并防范sql注入攻击的代码

    2024-01-28 08:03:47
  • 实例解析Python设计模式编程之桥接模式的运用

    2021-06-03 18:48:04
  • Django创建一个后台的基本步骤记录

    2021-03-19 02:13:38
  • python Event事件、进程池与线程池、协程解析

    2023-09-06 00:39:19
  • PJBlog3优化——单击自动输入验证码

    2009-05-17 11:03:00
  • Python实现复制图片到指定文件夹并按顺序重新命名

    2022-04-25 18:53:06
  • 如何在ADO中使用SQL函数?

    2010-06-17 12:51:00
  • python模块之subprocess模块级方法的使用

    2022-05-10 03:28:32
  • python的dict,set,list,tuple应用详解

    2023-03-01 17:48:38
  • ASP + Serv-u 实现FTP的代码

    2009-02-02 09:52:00
  • Python的for和break循环结构中使用else语句的技巧

    2022-07-02 16:59:26
  • Windows下Python使用Pandas模块操作Excel文件的教程

    2021-01-05 23:07:40
  • 一个提高了近10%转化率的改进

    2009-05-22 12:40:00
  • “生活”设计

    2009-03-03 12:14:00
  • Python中的枚举函数enumerate()的具体用法

    2022-06-03 13:33:31
  • python time.sleep()是睡眠线程还是进程

    2022-04-09 17:33:16
  • jsp include文件时的一个乱码解决方法

    2024-03-27 19:34:28
  • 在Python的Flask框架下收发电子邮件的教程

    2021-03-05 08:54:37
  • asp之家 网络编程 m.aspxhome.com