必须会的SQL语句(二) 创建表、修改表结构、删除表

栏目: 数据库 · SQL Server · 发布时间: 8年前

内容简介:这篇文章主要介绍了sqlserver中创建表、修改表结构、删除表的sql语句,需要的朋友可以参考下

这篇文章主要介绍了sql server中创建表、修改表结构、删除表的sql语句,需要的朋友可以参考下

1.创建数据库表

--使用哪个数据库,如果不写这一句是默认的数据库,也可以用鼠标选当前数据库
use testDB
--创建表
  Create Table tablename
  (
     --id表示字段名
     --int 数据类型
     --primary key 主键
     --not null 非空
     --identity(1,1)初始值是1 每次自增长1
     id int primary key not null identity(1,1),
     --unique 唯一
     name varchar(20) not null unique
  )

2.删除表

Drop table 表名

3.修改表结构

--增加列

Alter table 表名 

Add 列名 类型

--删除列

Alter table 表名 

  drop cloumn 列名

--修改列,修改列类型

Alter table 表名

Alter column 列名 type

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Algorithm Design Manual

The Algorithm Design Manual

Steven S Skiena / Springer / 2011-11-14 / GBP 55.07

....The most comprehensive guide to designing practical and efficient algorithms.... Written by a well-known algorithms researcher who received the IEEE Computer Science and Engineering Teaching Aw......一起来看看 《The Algorithm Design Manual》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具