Sybase常用表操作

Sybase常用表操作

>>表创建

创建一名为'rds_custom_ftp'的表,并设置ID Gap为1000.

create table rds_custom_ftp(
   sid   numeric(12,0)  identity,
   sub_no   int  not null,
   ftp_url   varchar(50)  not null,
   ftp_port   int  null,
   ftp_login   varchar(50)  not null,
   ftp_pass   varchar(50)  not null,
   ftp_dir   varchar(50)  null,
   active   char(1)  not null,
   entry_id   int  null,
   entry_datetime   datetime  not null,
   delete_id   int  null,
   delete_datetime   datetime  null,
   unzip   char(1)  null,
   new_filename   varchar(50)  null,
   ihms_work_time   float  not null,
   extension   varchar(20)  null
)with identity_gap = 1000

>>表重命名

重命名表'rds_custom_ftp'为'rds_custom_ftp2'

exec sp_rename 'rds_custom_ftp','rds_custom_ftp2'

>>表删除

删除表'rds_custom_ftp2'

drop table rds_custom_ftp2

>>列添加

添加列'suffix'

alter table rds_custom_ftp add suffix varchar(30) null

>>列修改

修改列'suffix'字符长度到50.

alter table rds_custom_ftp modify suffix varchar(50) null

>>列重命名

重命名列'suffix'到'suffix2'

exec sp_rename 'rds_custom_ftp.suffix','suffix2','column'

>>列删除

删除列'suffix2'

alter table rds_custom_ftp drop suffix2

>>索引添加

create clustered index rds_custom_ftpI1 on rds_custom_ftp( sub_no ASC)

>>索引重命名

重命名索引'rds_custom_ftpI1'到'rds_custom_ftpI111'

exec sp_rename 'rds_custom_ftp.rds_custom_ftpI1','rds_custom_ftpI111','index'

>>索引删除

drop index rds_custom_ftp.rds_custom_ftpI111

猜你喜欢

转载自jerval.iteye.com/blog/1997361