當前位置:首頁 » 操作系統 » 查詢資料庫表的數量

查詢資料庫表的數量

發布時間: 2023-09-08 19:07:38

sqlserver查詢資料庫中有多少個表

select * from sys.tables

㈡ 在oracle資料庫中如果查詢一個資料庫中有哪幾張表

1、本文以plsql圖形化管理工具為例,使用它連接oracle資料庫。當點開plsql的時候,就需要輸入用戶名、密碼、資料庫然後連接。如果連接成功,就能查看裡面的表等等操作,如果連接不成功,就輸入正確的信息再次嘗試。

㈢ 怎樣用SQL語句查詢一個資料庫中的所有表

TABLE 語句

具體語法:TABLE table_name [ORDER BY column_name] [LIMIT number [OFFSET number]]
其實從語法上看,可以排序,也可以過濾記錄集,不過比較簡單,沒有 SELECT 那麼強大。

示例 1

簡單的建一張很小的表 y1,記錄數為 10 條。表 t1,插入 10 條記錄

  • mysql-(ytt/3305)->create table t1 (r1 int,r2 int);

  • Query OK, 0 rows affected (0.02 sec)

  • mysql-(ytt/3305)->insert into t1

  • with recursive aa(a,b) as (

  • select 1,1

  • union all

  • select a+1,ceil(rand()*20) from aa where a < 10

  • ) select * from aa;

  • Query OK, 10 rows affected (0.00 sec)

  • Records: 10 Duplicates: 0 Warnings: 0

  • 簡單全表掃描mysql-(ytt/3305)->select * from t1;+------+------+| r1 | r2 |+------+------+| 1 | 1 || 2 | 9 || 3 | 9 || 4 | 17 || 5 | 17 || 6 | 16 || 7 | 6 || 8 | 1 || 9 | 10 || 10 | 3 |+------+------+10 rows in set (0.00 sec)

  • TABLE 結果mysql-(ytt/3305)->table t1;+------+------+| r1 | r2 |+------+------+| 1 | 1 || 2 | 9 || 3 | 9 || 4 | 17 || 5 | 17 || 6 | 16 || 7 | 6 || 8 | 1 || 9 | 10 || 10 | 3 |+------+------+10 rows in set (0.00 sec)

  • 看下 table 的執行計劃mysql-(ytt/3305)->explain table t1 order by r1 limit 2G*************************** 1. row *************************** id: 1 select_type: SIMPLE table: t1 partitions: NULL type: ALLpossible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 10 filtered: 100.00 Extra: Using filesort1 row in set, 1 warning (0.00 sec)

  • 其實可以看到 TABLE 內部被 MySQL 轉換為 SELECT 了。mysql-(ytt/3305)->show warningsG*************************** 1. row *************************** Level: Note Code: 1003Message: /* select#1 */ select `ytt`.`t1`.`r1` AS `r1`,`ytt`.`t1`.`r2` AS `r2` from `ytt`.`t1` order by `ytt`.`t1`.`r1` limit 21 row in set (0.00 sec)

  • 那其實從上面簡單的例子可以看到 TABLE 在內部被轉成了普通的 SELECT 來處理。示例 2應用於子查詢里的子表。這里要注意,內表的欄位數量必須和外表過濾的欄位數量一致。克隆表 t1 結構mysql-(ytt/3305)->create table t2 like t1;Query OK, 0 rows affected (0.02 sec)

  • 克隆表 t1 數據mysql-(ytt/3305)->insert into t2 table t1;Query OK, 10 rows affected (0.00 sec)Records: 10 Duplicates: 0 Warnings: 0

  • table t1 被當做內表,表 t1 有兩個欄位,必須同時滿足 t2 檢索時過濾的欄位也是兩個。mysql-(ytt/3305)->select * from t2 where (r1,r2) in (table t1);+------+------+| r1 | r2 |+------+------+| 1 | 1 || 2 | 9 || 3 | 9 || 4 | 17 || 5 | 17 || 6 | 16 || 7 | 6 || 8 | 1 || 9 | 10 || 10 | 3 |+------+------+10 rows in set (0.00 sec)

  • 注意:這里如果過濾的欄位數量和子表數量不一致,則會報錯。

㈣ DB2中如何查詢一個資料庫中有多少張表

資料庫中還有大量系統表的,所以我覺得你查某些模此信慶式下的表比較好坦搜:
select count(*) from syscat.tables where tabschema='GP'
GP為某用戶模式。
當然也可以用
select count(*) from syscat.tables where tabschema='GP'
查出所有表的數量。
再查出有多少張系統表,就是在SYSIBM、SYSTOOLS下的表數目。相減就可以了。
我森握用的是DB2 V9.7。

熱點內容
如何判斷伺服器被多少人訪問 發布:2025-05-19 19:27:45 瀏覽:123
編程stata 發布:2025-05-19 19:12:18 瀏覽:513
解壓命令gz 發布:2025-05-19 19:11:37 瀏覽:823
linux下的程序開發 發布:2025-05-19 18:55:02 瀏覽:927
該文件夾未包含 發布:2025-05-19 18:54:17 瀏覽:195
安卓拳皇對戰用哪個平台 發布:2025-05-19 18:42:39 瀏覽:531
華為暢玩5怎麼取消鎖屏密碼 發布:2025-05-19 18:42:38 瀏覽:583
linuxrm文件夾 發布:2025-05-19 18:40:25 瀏覽:973
譚浩強c語言錯誤 發布:2025-05-19 18:39:33 瀏覽:952
安卓和蘋果用流量哪個劃算 發布:2025-05-19 18:38:04 瀏覽:409