banxitan

统计

留言簿(2)

阅读排行榜

评论排行榜

Sysbase 中判断某表是否存在(表所对应的索引名是否存在的判断方法)

今天在写动态建表及表所对应的索引时,需要判断表及索引是否存在。现记录如下。。

判断表是否存在

select id,name from sysobjects where type='U' and name='Airbook';
其中 Airbook是所需要创建的表名。。

判断表所对应的索引名是否存在
select sysobjects.id,sysobjects.name ,sysindexes.name 
from sysobjects,sysindexes
where sysobjects.id = sysindexes.id  and 
      sysobjects.type
='U'
        
and sysobjects.name='Airbook'
        
and sysindexes.name='in_abksaleid'
;
其中 Airbook是指表名, in_abksaleid 是指所建的索引名。

查询表中的某个字段是否存在


select sysobjects.id,sysobjects.name ,syscolumns.name 
from sysobjects,syscolumns
where sysobjects.id = syscolumns.id  and 
      sysobjects.type
='U'
        
and sysobjects.name='Airbook'
        
and syscolumns.name='Agent_ID'
;

其中Airbook是指表名,Agent_ID为Airbook的字段

posted on 2009-07-20 21:14 MikyTan 阅读(968) 评论(0)  编辑  收藏 所属分类: SQL


只有注册用户登录后才能发表评论。


网站导航: