获得数据库中表字段的名字.txt
生活随笔
收集整理的這篇文章主要介紹了
获得数据库中表字段的名字.txt
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
獲得數據庫中所有數據庫的名字:select name From sysdatabases
獲得某個數據庫中所有表的名字:select name from sysobjects where type='U'
獲得某個表中字段的名字:select name from syscolumns? where id=object_id('表名')
use master
if exists(SELECT * From sysdatabases where name='test3')
drop database? test3
create database test3
go
use test3
go
if exists (select * from sysobjects where type='U' and name='abc')
drop table abc
create table abc (
id int not null identity(20011001,1) primary key clustered,
name varchar(6) not null ,class int null , time1 datetime default getdate())
insert into abc ?
select 'a',1,1 union all
select 'b',2,2
insert into abc values('a',null,default)
獲得某個數據庫中所有表的名字:select name from sysobjects where type='U'
獲得某個表中字段的名字:select name from syscolumns? where id=object_id('表名')
use master
if exists(SELECT * From sysdatabases where name='test3')
drop database? test3
create database test3
go
use test3
go
if exists (select * from sysobjects where type='U' and name='abc')
drop table abc
create table abc (
id int not null identity(20011001,1) primary key clustered,
name varchar(6) not null ,class int null , time1 datetime default getdate())
insert into abc ?
select 'a',1,1 union all
select 'b',2,2
insert into abc values('a',null,default)
總結
以上是生活随笔為你收集整理的获得数据库中表字段的名字.txt的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 爬虫入门练习
- 下一篇: Android Activity无法启动