All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
数据库用SQL语法大全_[SQL Server教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/3 6:45:58 Browse times: 432 Comment times: 0

数据库用SQL语法大全_[SQL Server教程]


Head photo

Go homepage
Upload pictures
Write articles

数据库用SQL语法大全_[SQL Server教程]   1、建表格:

  create table table_name( column1 datatype [not null] [not null primary key], column2 datatype [not null],...)

  说明: 

  datatype --是资料的格式,详见表。
  nut null --可不可以允许资料有空的(尚未有资料填入)。
  primary key --是本表的主键。

  2、更改表格 

  alter table table_name add column column_name datatype

  说明:增加一个栏位(没有删除某个栏位的语法。)

  lter table table_name add primary key (column_name)

  说明:更改表得的定义把某个栏位设为主键。
  
  alter table table_name drop primary key (column_name)

  说明:把主键的定义删除。

  3、建立索引 

  create index index_name on table_name (column_name)

  说明:对某个表格的栏位建立索引以增加查询时的速度。

  4、删除 

  drop table_name

  drop index_name

  二、资料形态 datatypes

  smallint
  16 位元的整数。

  interger
  32 位元的整数。

  decimal(p,s)
  p 精确值和 s 大小的十进位整数,精确值p是指全部有几个数(digits)大小值,s是指小数後有几位数。如果没有特别指定,则系统会设为 p=5; s=0 。

  float
  32位元的实数。

  double
  64位元的实数。

  char(n)
  n 长度的字串,n不能超过 254。

  varchar(n)
  长度不固定且其最大长度为 n 的字串,n不能超过 4000。




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.