几个简单的DB2操作语句

数据库
下位为您列举了一些例如建表等基础常见的DB2操作语句,供您参考,希望可以让您对DB2特别是DB2语句有更深入的认识。

DB2操作语句究竟和其他数据库的操作语句写法有何不同呢?下面为您举个简单的DB2操作语句例子,供您比较学习,希望对您有所帮助。

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
说明:增加一个栏位(没有删除某个栏位的语法。
alter 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

以上就是简单的DB2操作语句的介绍。

 

【编辑推荐】

DB2隔离级别--为落实的读

DB2动态SQL的使用

DB2循环查询的实现

DB2信息目录中心简介

DB2游标及其使用

责任编辑:段燃 来源: 互联网
相关推荐

2010-09-06 15:13:05

DB2

2010-11-04 15:39:40

DB2 SQL语句

2010-11-04 11:17:42

DB2 Merge语句

2010-11-01 11:13:57

DB2表管理

2010-11-04 11:39:47

2010-11-02 14:53:38

DB2权限

2010-08-09 09:50:29

整理DB2数据集

2010-11-02 15:36:18

DB2建表语句

2010-08-16 15:37:37

DB2 -964问题

2010-08-04 15:10:47

2010-07-27 15:44:21

db2建立databa

2010-07-27 15:52:09

DB2数据移动

2010-11-04 09:31:21

DB2循环语句

2010-08-17 13:37:18

DB2 Online

2010-08-16 09:39:03

DB2基础知识DB2c

2009-04-01 11:39:39

视图DB2

2010-09-30 10:53:39

DB2表管理

2010-08-03 13:56:11

DB2表复制

2010-11-04 12:00:59

db2存储过程

2010-08-18 08:53:23

DB2 SELECT语
点赞
收藏

51CTO技术栈公众号