❶ mysql資料庫怎麼查看錶結構
登陸mysql
命令:
mysql -uroot -p
此處以mysql資料庫的func表為例
查看錶結構的方法1
命令:
desc func;
方法2
命令:
describe func;
方法3
命令:
show columns from func;
方法3
命令:
explain func;
方法3
使用mysql的工具mysqlshow.exe
mysql 資料庫 表
❷ mysql中查詢資料庫中表名稱和結構的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查詢資料庫所有的表名稱和表結構的sql語句怎麼寫
查詢MySQL資料庫所有表名的SQL命令:
show tables;
CREATE TABLE `students` (
`sid` char(10) NOT NULL,
`sname` varchar(50) NOT NULL,
`sex` char(1) NOT NULL,
`dob` date NOT NULL,
`phone` varchar(30) DEFAULT NULL,
PRIMARY KEY (`sid`),
KEY `index_tbl1_url` (`phone`(20))
) ENGINE=InnoDB DEFAULT CHARSET=gb2312
❹ mysql常用命令都有哪些
1.導出整個資料庫
mysqlmp-u用戶名-p–default-character-set=latin1資料庫名》導出的文件名(資料庫默認編碼是latin1)23mysqlmp-uwcnc-psmgp_apps_wcnc》wcnc.sql
2.導出一個表
mysqlmp-u用戶名-p資料庫名表名》導出的文件名23mysqlmp-uwcnc-psmgp_apps_wcncusers》wcnc_users.sql
3.導出一個資料庫結構
mysqlmp-uwcnc-p-d–add-drop-tablesmgp_apps_wcnc》d:wcnc_db.sql23-d沒有數據–add-drop-table在每個create語句之前增加一個droptable
4.導入資料庫
A:常用source命令23進入mysql資料庫控制台,45如mysql-uroot-p67mysql》use資料庫89然後使用source命令,後面參數為腳本文件(如這里用到的.sql)1011mysql》sourcewcnc_db.sql1213B:使用mysqlmp命令1415mysqlmp-uusername-pdbname《filename.sql1617C:使用mysql命令1819mysql-uusername-p-Ddbname《filename.sql啟動與退出
1、進入MySQL:啟動MySQLCommandLineClient(MySQL的DOS界面),直接輸入安裝時的密碼即可。此時的提示符是:mysql》
2、退出MySQL:quit或exit
5.創建資料庫
命令:createdatabase《資料庫名》
例如:建立一個名為xhkdb的資料庫
mysql》createdatabasexhkdb;
6.顯示所有的資料庫
命令:showdatabases(注意:最後有個s)
mysql》showdatabases;
7.刪除資料庫
命令:dropdatabase《資料庫名》
8.連接資料庫
命令:use《資料庫名》
例如:如果xhkdb資料庫存在,嘗試存取它:
9.查看當前使用的資料庫
mysql》selectdatabase();
10.當前資料庫包含的表信息:
mysql》showtables;(注意:最後有個s)
❺ mysql 資料庫怎麼根據名字去查數據 命令
所有資料庫名的命令
show
databases
表結構和列結構
desc
tablename
進入MySQL
Command
line
client下查看當前使用的資料庫:mysql>select
database();mysql>status;mysql>show
tables;mysql>show
databases;//可以查看有哪些資料庫,返回資料庫名(databaseName)mysql>use
databaseName;
//更換當前使用的資料庫mysql>show
tables;
//返回當前資料庫下的所有表的名稱或者也可以直接用以下命令mysql>show
tables
from
databaseName;//databaseName可以用show
databases得來mysql查看錶結構命令
❻ 如何查看mysql資料庫
查看當前使用的資料庫,可使用如下命令
mysql> select database(); #使用函數database()
mysql> show tables; #列頭信息中可看出當前使用的db,格式為:Tables_in_[db_name]
mysql> status; #注意結果中的"Current database:"信息
查看系統中有哪些資料庫,
mysql> show databases;
更換當前使用的資料庫,
mysql> use db_name;
返回當前資料庫下的所有表的名稱
mysql> show tables;
或者直接用如下命令
mysql> show tables from db_name;
查看錶結構,可使用如下命令
mysql> desc 表名;
mysql> describe 表名;
mysql> show columns from 表名;
mysql> show create table 表名;
或者,
mysql> use information_schema
mysql> select * from columns where table_name='表名';
15個 MySQL 菜鳥問題
問題1:你如何確定 MySQL 是否處於運行狀態?
答案: Debian 上運行命令 service mysql status,在RedHat 上運行命令 service mysqld status。然後看看輸出即可。
問題2:如何開啟或停止 MySQL 服務?
答案:運行命令 service mysqld start 開啟服務;運行命令 service mysqld stop 停止服務。
問題3:如何通過 Shell 登入 MySQL?
答案:運行命令 mysql -u root -p
問題4:如何列出所有資料庫?
答案:運行命令 show databases;
問題5: 如何切換到某個資料庫並在上面工作?
答案:運行命令 use database_name; 進入名為 database_name 的資料庫。
問題6:如何列出某個資料庫內所有表?
答案:在當前資料庫運行命令 show tables;
問題7:如何獲取表內所有 Field 對象的名稱和類型?
答案:運行命令 describe table_name;
問題8:如何刪除表?
答案:運行命令 drop table table_name;
問題9:如何刪除資料庫?
答案:運行命令 drop database database-name;
問題10:如何查看錶內所有數據?
答案:運行命令 select * from table_name;
問題11:如何從表(比如 oc_users )中獲取一個 field 對象(比如 uid)的所有數據?
答案:運行命令 select uid from oc_users;
問題12:假設你有一個名為 『xyz』 的表,它存在多個欄位,如 『createtime』 和 『engine』。名為 engine 的欄位由 『Memoty』 和 『MyIsam』 兩種數值組成。如何只列出 『createtime』 和 『engine』 這兩列並且 engine 的值為 『MyIsam』?
答案:運行命令 select create_time, engine from xyz where engine = 」MyIsam」;
問題13:如何列出表 『xrt』 內 name 域值為 『tecmint』,web_address 域值為 『tecmint.com』 的所有數據?
答案:運行命令 select * from xrt where name = 「tecmint」 and web_address = 「tecmint.com」;
問題14:如何列出表 『xrt』 內 name 域值不為 『tecmint』,web_address 域值為 『tecmint.com』 的所有數據?
答案:運行命令 select * from xrt where name != "tecmint" and web_address = "tecmint.com";
問題15:如何知道表內行數?
答案:運行命令 select count(*) from table_name;
❼ mysql咋查看一個資料庫有多少張表的命令
啟動mysql服務
連接mysql 可用工具,也可直接在dos下連接
use databases; 打開需要查看的庫
show tables; 可顯示所有的表
❽ mysql怎麼查看錶結構和注釋
MySQL 查看錶結構簡單命令。
一、簡單描述表結構,欄位類型desc tabl_name;
顯示表結構,欄位類型,主鍵,是否為空等屬性,但不顯示外鍵。
二、查詢表中列的注釋信息
select * from information_schema.columns where table_schema = 'db' #表所在資料庫
and table_name = 'tablename' ; #你要查的表
三、只查詢列名和注釋
select column_name,
column_comment from information_schema.columns where table_schema ='db' and
table_name = 'tablename' ;
四、#查看錶的注釋
select table_name,table_comment from information_schema.tables where table_schema = 'db' and table_name ='tablename'
ps:二~四是在元數據表中查看,我在實際操作中,常常不靈光,不知為什麼,有了解的大俠請留印。
五、查看錶生成的DDL show create table table_name;
❾ 怎樣使用命令行查看mysql資料庫
使用命令行連接mysql資料庫:
windows操作系統下,開始——運行,打開"運行"對話框,輸入cmd,點擊「確定」即可進入dos窗口。
dos窗口輸入登錄mysql資料庫命令
mysql
-h
127.0.0.1
-u
root
-p
命令參數說明:
mysql是登錄資料庫的命令,-h
後面跟伺服器的ip,由於本示例mysql伺服器安裝在本地,因此ip地址為127.0.0.1;-u
後面跟用戶名,本示例採用
root用戶登錄;-p
後面跟登錄密碼。
輸入上述命令後回車,再輸入登錄密碼,在回車即可完成登錄mysql資料庫服務了。跟著可以運行use
databasename語句操作某個資料庫了
❿ mysql如何查看資料庫結構
1.在MySQL資料庫中通過show tables命令;查看資料庫中所有數據表
2.在MySQL資料庫中通過desc tablename;查看錶結構