第一,mysql查看表結(jié)構(gòu)命令,如下:
desc 表名;
show columns from 表名;
或者
describe 表名;
show create table 表名;
或者
use information_schema
select * 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ù)庫與表的最基本命令,如下:
SELECT DATABASE();
列出當前所選擇的數(shù)據(jù)庫,如果未選擇數(shù)據(jù)庫則顯示NULL;
SHOW DATABASES;
列出服務(wù)器上當前存在的MySQL數(shù)據(jù)庫;
USE databasename;
選擇訪問某個數(shù)據(jù)庫;
SHOW tables;
找出當前的MySQL數(shù)據(jù)庫包含什么表;
DESCRIBE tablename;
列出一個表的結(jié)構(gòu);
SHOW INDEX FROM tablename;
顯示表中的索引信息。