sql常用sql語句

2021-07-16 16:44:54 字數 736 閱讀 4970

1、查詢某個庫中所有的表名字

select [name] from sysobjects where xtype='u'and [name]<>'dtproperties' order by [name]

2、得到資料庫中所有使用者檢視

select [name] from sysobjects where xtype='v' and [name]<>'syssegments' and [name]<>'sysconstraints' order by [name]

3、獲得指定表中所有的列

select

c.name as columnname,

t.name as typename

from syscolumns c, systypes t, sysobjects o

where c.xtype = t.xusertype

and c.id = o.id

and o.name = 'book'

order by c.colorder

4、查詢庫中所有表的名字,以及表中資料的行數

select   a.name, b.rows

from   sysobjects as a inner join

sysindexes as b on a.id = b.id

where   (a.type = 'u') and (b.indid in (0, 1))

order by b.rows desc

常用sql語句

t sql語句複製表的方法 我在sql server 2000中有現個資料庫datahr及demo,它們的結構是一樣,其它有乙個表名為 gbitem.現在我想將demo資料庫的表名 gbitem的全部內容複製到datahr資料庫的表名為 gbitem中。請問此t sql語句應該怎麼寫?謝謝高人指點!...

常用SQL語句

查詢 sp who 中的結果值。因為儲存過程不能查詢,先轉為臨時表再查詢。declare tb table spid varchar 100 ecid varchar 100 status varchar 100 loginame varchar 100 hostname varchar 100 b...

常用SQL語句

select sysdate from dual desc tablea insert into table name values 1,aaaa 34 update table name set aa aa where x delete from table name where x alter ...