--讀取庫中的所有表名 select name from sysobjects where xtype='u' --讀取指定表的所有列名 select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='表名') 獲取資料庫表名和欄位 sqlserver中各個系統表的作用 sysaltfiles 主資料庫 保存資料庫的文件 syscharsets 主資料庫 字元集與排序順序 sysconfigures 主資料庫 配置選項 syscurconfigs 主資料庫 當前配置選項 sysdatabases 主資料庫 伺服器中的資料庫 syslanguages 主資料庫 語言 syslogins 主資料庫 登陸帳號信息 sysoledbusers 主資料庫 鏈接伺服器登陸信息 sysprocesses 主資料庫 進程 sysremotelogins主資料庫 遠程登錄帳號 syscolumns 每個資料庫 列 sysconstrains 每個資料庫 限制 sysfilegroups 每個資料庫 文件組 sysfiles 每個資料庫 文件 sysforeignkeys 每個資料庫 外部關鍵字 sysindexs 每個資料庫 索引 sysmenbers 每個資料庫 角色成員 sysobjects 每個資料庫 所有資料庫對象 syspermissions 每個資料庫 許可權 systypes 每個資料庫 用戶定義數據類型 select 列名=name from syscolumns where id=object_id(N'要查的表名')
B. 怎樣用SQL語句查詢一個資料庫中的所有表
--讀取庫中的所有表名
select name from sysobjects where xtype='u'
--讀取指定表的所有列名
select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='表名')
獲取資料庫表名和欄位
sqlserver中各個系統表的作用
sysaltfiles 主資料庫 保存資料庫的文件
syscharsets 主資料庫 字元集與排序順序
sysconfigures 主資料庫 配置選項
syscurconfigs 主資料庫 當前配置選項
sysdatabases 主資料庫 伺服器中的資料庫
syslanguages 主資料庫 語言
syslogins 主資料庫 登陸帳號信息
sysoledbusers 主資料庫 鏈接伺服器登陸信息
sysprocesses 主資料庫 進程
sysremotelogins主資料庫 遠程登錄帳號
syscolumns 每個資料庫 列
sysconstrains 每個資料庫 限制
sysfilegroups 每個資料庫 文件組
sysfiles 每個資料庫 文件
sysforeignkeys 每個資料庫 外部關鍵字
sysindexs 每個資料庫 索引
sysmenbers 每個資料庫 角色成員
sysobjects 每個資料庫 所有資料庫對象
syspermissions 每個資料庫 許可權
systypes 每個資料庫 用戶定義數據類型
select 列名=name from syscolumns where id=object_id(N'要查的表名')
C. 如何查看SQL資料庫內容
1、首先,打開SQL Server的電腦軟體,進入軟體載入界面等待載入。
D. 怎樣用SQL語句查詢一個資料庫中的所有表
查詢資料庫里所有表名和欄位名的語句
SQL 查詢所有表名:
SELECT NAME FROM SYSOBJECTS WHERE TYPE='U'
SELECT * FROM INFORMATION_SCHEMA.TABLES
結構化查詢語言(Structured Query Language)簡稱SQL,結構化查詢語言是一種資料庫查詢和程序設計語言,用於存取數據以及查詢、更新和管理關系資料庫系統;
sql 語句就是對資料庫進行操作的一種語言。
(4)sql資料庫界面查詢表信息擴展閱讀:
SQL語句常見語句:
1、更新:update table1 set field1=value1 where 范圍;
2、查找:select * from table1 where field1 like 』%value1%』 (所有包含『value1』這個模式的字元串);
3、排序:select * from table1 order by field1,field2 [desc];
4、求和:select sum(field1) as sumvalue from table1;
5、平均:select avg(field1) as avgvalue from table1;
6、最大:select max(field1) as maxvalue from table1;
7、最小:select min(field1) as minvalue from table1[separator]。
參考資料來源:網路-sql語句
E. 怎樣用SQL語句查詢一個資料庫中的所有表
1、打開Microsoft SQL Server 2012,選中需要查詢所有表的資料庫。
F. SQL如何查詢一個資料庫中的表
第一次回答:
寫存儲過程或者函數來做。
第二次回答:
過程如下,你還可以完善一下
create procere get_table
@colname varchar(30),
@colvalue varchar(30),
@coltype varchar(30)=null,
@colformat varchar(30)=null
as
begin
declare @sql varchar(100), @tablename varchar(30)
create table #tables( tablename varchar(30))
declare cur_table cursor for
select name from sysobjects a
where type = 'U' and uid = 1 and exists( select 1 from syscolumns b where b.id = a.id and b.name = @colname)
open cur_table
fetch cur_table into @tablename
WHILE @@FETCH_STATUS = 0 begin
select @sql = 'insert into #tables select'''+ @tablename +''' where exists( select 1 from '+ @tablename +' where '+ @colname +' = '''+ @colvalue +''')'
exec(@sql)
fetch cur_table into @tablename
end
close cur_table
deallocate cur_table
select * from #tables
end
go
exec get_table 'name', '張三'
第三次回答:
這個過程我在SQL server 2005中執行過了,沒有問題,而且這語法也在2000中適用。
過程,我寫了幾次,或許你看得是開始我寫的,那有錯,後來更正了。
如果報錯,請把錯誤貼出來。
第四次回答:
你要把你的過程及語句,貼出來嘛,或者說明沒有改動,完全按照我的,那你也得把你的SQL語句貼出來吧?
然後,你說:
報錯如下,我是新手 麻煩大家了:
(所影響的行數為 0 行)
伺服器: 消息 105,級別 15,狀態 1,行 1
字元串 '張' 之前有未閉合的引號。
伺服器: 消息 170,級別 15,狀態 1,行 1
第 1 行: '張' 附近有語法錯誤。
(所影響的行數為 0 行)
伺服器: 消息 170,級別 15,狀態 1,行 1
第 1 行: '=' 附近有語法錯誤。
為什麼有那麼多報錯?是否執行了一次語句就報了你列出的所有錯誤?
務必把你的語句貼出來。像我第三次回答一樣,建立過程的語句(如果你沒有改,則不需要列出只需要說明,沒有改即可),及執行過程的語句(如果你沒有改,則不需要列出只需要說明,沒有改即可)。
第四次回答:
你重新執行一遍一下語句:
選中到「--到這里結束」的語句,一次執行。
drop procere get_table
go
create procere get_table
@colname varchar(30),
@colvalue varchar(30),
@coltype varchar(30)=null,
@colformat varchar(30)=null
as
begin
declare @sql varchar(100), @tablename varchar(30)
create table #tables( tablename varchar(30))
declare cur_table cursor for
select name from sysobjects a
where type = 'U' and uid = 1 and exists( select 1 from syscolumns b where b.id = a.id and b.name = @colname)
open cur_table
fetch cur_table into @tablename
WHILE @@FETCH_STATUS = 0 begin
select @sql = 'insert into #tables select'''+ @tablename +''' where exists( select 1 from '+ @tablename +' where '+ @colname +' = '''+ @colvalue +''')'
exec(@sql)
fetch cur_table into @tablename
end
close cur_table
deallocate cur_table
select * from #tables
end
go
exec get_table 'name, '張三'
--到這里結束
如果仍有問題,那麼執行以下語句:
create table #tables( tablename varchar(30))
insert into #tables select a.name from sysobjects a
where type = 'U' and uid = 1 and exists( select 1 from syscolumns b where b.id = a.id and b.name = 'name')
select * from #tables
drop table #tables
可以把所有包含欄位'name'的表找出來,你自己再仔細研究,使用exec( SQL)的方式 SQL2000也是支持的,實在不行,你就找到表後,自己一個一個表再select也可以得到結果:
select count(1) from tablename where name = '張三'
結果大於零就說明這個表是你要找的表之一了。
自己研究下吧。
G. 怎樣看SQL資料庫中哪些表有數據
兩種
方式
,一種是直接在
sqlserver
的列表中找到,另一種用寫
語句
的方式查詢。
方法一:
1、登陸SQL
SERVER
Manager
Studio。
2、在左邊的樹找到自己要查詢的資料庫。如圖:
3、點擊「表」,就能看到這個庫中的所有表了。
方法二:
1、登陸SQL
SERVER
Manager
Studio。
2、點擊左上角的「新建查詢」。
3、在窗口中編寫
sql語句
如下,然後運行
='U'ORDERBYName
結果截圖:
H. mysql如何進入資料庫查看所有表
1.查看資料庫,選中使用資料庫,並查看資料庫表,具體操作命令如下:
show databases;
use student;
show tables;
(8)sql資料庫界面查詢表信息擴展閱讀:
可以使用命令行工具管理 MySQL 資料庫(命令 mysql 和 mysqladmin),也可以從 MySQL 的網站下載圖形管理工具 MySQL Administrator, MySQL Query Browser 和 MySQL Workbench。
phpMyAdmin是由 php 寫成的 MySQ L資料庫系統管理程程序,讓管理者可用 Web 界面管理 MySQL 資料庫。
phpMyBackupPro也是由 PHP 寫成的,可以透過 Web 界面創建和管理資料庫。它可以創建偽 cronjobs,可以用來自動在某個時間或周期備份 MySQL 資料庫。
另外,還有其他的 GUI 管理工具,例如 mysql-front 以及 ems mysql manager,navicat等等。
I. SQL資料庫,如何查詢資料庫內含有某一列(某欄位,如name)的所有表
SQL資料庫,查詢包含列(欄位,如名稱)的資料庫中的所有表的步驟如下:需要准備的材料是:計算機,sql finder。
1,首先,打開sql查詢器並連接到相應的數據連接,例如測試庫。