MySQL 查看表结构、索引、触发器 的SQL语句

ysql> show index from t1;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| t1 | 0 | PRIMARY | 1 | id | A | NULL | NULL | NULL | | BTREE | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
1 row in set (0.00 sec)

mysql>
mysql> show create table t1;
+-------+-----------------------------------------------------------------------
| Table | Create Table
+-------+-----------------------------------------------------------------------
| t1 | CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`col` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------
1 row in set (0.00 sec)

mysql> desc t1;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| col | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> show columns from t1;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| col | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> show full columns from t1;
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
| id | int(11) | NULL | NO | PRI | NULL | | select,insert,update,references | |
| col | int(11) | NULL | YES | | NULL | | select,insert,update,references | |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
2 rows in set (0.00 sec)

mysql>

mysql> show triggers like 'test1';
+---------+--------+-------+----------------------------------------------------
--------------------------------------------------------------------------------
---------------+--------+---------+---------------------------------------------
-------------------+----------------+----------------------+--------------------
--+--------------------+
| Trigger | Event | Table | Statement

| Timing | Created | sql_mode
| Definer | character_set_client | collation_connectio
n | Database Collation |
+---------+--------+-------+----------------------------------------------------
--------------------------------------------------------------------------------
---------------+--------+---------+---------------------------------------------
-------------------+----------------+----------------------+--------------------
--+--------------------+
| testref | INSERT | test1 | BEGIN
INSERT INTO test2 SET a2 = NEW.a1;
DELETE FROM test3 WHERE a3 = NEW.a1;
UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;
END | BEFORE | NULL | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUB
STITUTION | root@localhost | latin1 | latin1_swedish_ci | latin
1_swedish_ci |
+---------+--------+-------+----------------------------------------------------
--------------------------------------------------------------------------------
---------------+--------+---------+---------------------------------------------
-------------------+----------------+----------------------+--------------------
--+--------------------+
1 row in set (0.00 sec)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值