使用SQL查詢所有數(shù)據(jù)庫(kù)名和表名問(wèn)題
MySQL中查詢所有數(shù)據(jù)庫(kù)名和表名
查詢所有數(shù)據(jù)庫(kù)
show databases;
查詢指定數(shù)據(jù)庫(kù)中所有表名
方法一、
use 數(shù)據(jù)庫(kù)名
show tables;
方法二、
select table_name from information_schema.tables where table_schema='數(shù)據(jù)庫(kù)名' and table_type='BASE TABLE';
查詢指定表中的所有字段名
select column_name from information_schema.columns where table_schema='數(shù)據(jù)庫(kù)名' and table_name='表名';
查詢指定表中的所有字段名和字段類(lèi)型
show create table 表名;
或者
select column_name,data_type from information_schema.columns where table_schema='數(shù)據(jù)庫(kù)名' and table_name='表名';
SQLServer中查詢所有數(shù)據(jù)庫(kù)名和表名
查詢所有數(shù)據(jù)庫(kù)
select * from sysdatabases;
查詢當(dāng)前數(shù)據(jù)庫(kù)中所有表名
select * from sysobjects where xtype='U';
xtype='U':表示所有用戶表xtype='S':表示所有系統(tǒng)表
查詢指定表中的所有字段名
select name from syscolumns where id=Object_Id('table_name');查詢指定表中的所有字段名和字段類(lèi)型
select sc.name,st.name from syscolumns sc,systypes st where sc.xtype=st.xtype and sc.id in(select id from sysobjects where xtype='U' and name='table_name');
Oracle中查詢所有數(shù)據(jù)庫(kù)名和表名
查詢所有數(shù)據(jù)庫(kù)
由于Oralce沒(méi)有庫(kù)名,只有表空間,所以O(shè)racle沒(méi)有提供數(shù)據(jù)庫(kù)名稱(chēng)查詢支持,只提供了表空間名稱(chēng)查詢。
select * from v$tablespace;--查詢表空間(需要一定權(quán)限)
查詢當(dāng)前數(shù)據(jù)庫(kù)中所有表名
select * from user_tables;
查詢指定表中的所有字段名
select column_name from user_tab_columns where table_name = 'table_name';--表名要全大寫(xiě)
查詢指定表中的所有字段名和字段類(lèi)型
select column_name, data_type from user_tab_columns where table_name = 'table_name';--表名要全大寫(xiě)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
mysql動(dòng)態(tài)游標(biāo)學(xué)習(xí)(mysql存儲(chǔ)過(guò)程游標(biāo))
mysql動(dòng)態(tài)游標(biāo)示例,通過(guò)準(zhǔn)備語(yǔ)句、視圖和靜態(tài)游標(biāo)實(shí)現(xiàn),大家參考使用吧2013-12-12
mybatis mysql delete in操作只能刪除第一條數(shù)據(jù)的方法
這篇文章主要介紹了mybatis mysql delete in操作只能刪除第一條數(shù)據(jù)的問(wèn)題及解決方法,需要的朋友可以參考下2018-09-09
MySQL數(shù)據(jù)庫(kù)學(xué)習(xí)之分組函數(shù)詳解
這篇文章主要為大家詳細(xì)介紹一下MySQL數(shù)據(jù)庫(kù)中分組函數(shù)的使用,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)MySQL有一定幫助,需要的可以參考一下2022-07-07
mysql修改數(shù)據(jù)庫(kù)引擎的幾種方法總結(jié)
這篇文章主要給大家介紹了關(guān)于mysql修改數(shù)據(jù)庫(kù)引擎的相關(guān)資料,包括使用ALTERTABLE語(yǔ)句、更改默認(rèn)存儲(chǔ)引擎、使用MySQLWorkbench、導(dǎo)出和導(dǎo)入數(shù)據(jù)以及編寫(xiě)腳本批量修改,每種方法都有其優(yōu)缺點(diǎn)和適用場(chǎng)景,需要的朋友可以參考下2024-11-11
MySQL數(shù)據(jù)庫(kù)的事務(wù)和索引詳解
這篇文章主要介紹了MySql 索引和事務(wù),總結(jié)分析了mysql數(shù)據(jù)庫(kù)中關(guān)于索引和事務(wù)的概念、原理、知識(shí)點(diǎn)及相關(guān)注意事項(xiàng),需要的朋友可以參考下2021-10-10

