查看MySQL數(shù)據(jù)庫表
進(jìn)入MySQL Command line client下
查看當(dāng)前使用的數(shù)據(jù)庫:
mysql>select database();mysql>status;mysql>show tables;mysql>show databases;//可以查看有哪些數(shù)據(jù)庫,返回數(shù)據(jù)庫名(databaseName)mysql>use databaseName; //更換當(dāng)前使用的數(shù)據(jù)庫mysql>show tables; //返回當(dāng)前數(shù)據(jù)庫下的所有表的名稱
或者也可以直接用以下命令
mysql>show tables from databaseName;//databaseName可以用show databases得來
mysql查看表結(jié)構(gòu)命令,如下:
desc 表名;show columns from 表名;
describe 表名;show create table 表名;
use information_schemaselect * from columns where table_name='表名';
Rows matched: 1 Changed: 0 Warnings: 1 mysql> show warnings; +---------+------+-------------------------------------------+ | Level | Code | Message | +---------+------+-------------------------------------------+ | Warning | 1265 | Data truncated for column 'name' at row 3 | +---------+------+-------------------------------------------+ 1 row in set
以上就是查看MySQL數(shù)據(jù)庫表的命令介紹。
MySQL清空表
Mysql清空表是很重要的操作,也是最常見的操作之一,下面就為您詳細(xì)介紹Mysql清空表的實現(xiàn)方法,希望能夠?qū)δ兴鶐椭?/p>
方法1:重建庫和表
用mysqldump --no-data把建表SQL導(dǎo)出來,然后drop database再create database,執(zhí)行一下導(dǎo)出的SQL文件,把表建上;
方法2:生成清空所有表的SQL
mysql -N -s information_schema -e "SELECT CONCAT('TRUNCATE TABLE ',TABLE_NAME,';') FROM TABLES WHERE TABLE_SCHEMA='eab12'"輸出結(jié)果如下:
TRUNCATE TABLE AUTHGROUPBINDINGS;TRUNCATE TABLE AUTHGROUPS;TRUNCATE TABLE AUTHUSERS;TRUNCATE TABLE CORPBADCUSTOMINFO;TRUNCATE TABLE CORPSMSBLACKLISYInfo;TRUNCATE TABLE CORPSMSFILTERINFO;TRUNCATE TABLE CORPSMSINFO;TRUNCATE TABLE EABASEREGINFOS;TRUNCATE TABLE EACORPBLOB;TRUNCATE TABLE EACORPINFO;........
這樣就更完善了:
以上就是Mysql清空表的實現(xiàn)方法。
新聞熱點(diǎn)
疑難解答
圖片精選