在MySQL中获取表元数据 [英] Getting table metadata in MySQL

查看:367
本文介绍了在MySQL中获取表元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何从MySQL 5.0中的表中获取以下约束信息:




  • 主键

  • 外键和表引用

  • 唯一列



<查询的语法是什么?我有一种感觉我很熟悉这< a>,但没有示例。

解决方案

SHOW COLUMNS 命令将显示表的主键和唯一列。



对于外键,您可以使用类似 SHOW CREATE TABLE 命令,它将输出复制表所需的DDL语句。


I'm trying to find out how to get the following constraint information from a table in MySQL 5.0:

  • primary key
  • foreign keys and table references
  • unique columns

What is the syntax of the query or queries to do so? I have a feeling I'm close with this, but there is no example.

解决方案

The SHOW COLUMNS command will show you the primary key and unique columns for a table.

As for foreign keys, you could use something like the SHOW CREATE TABLE command which will output the DDL statements needed to replicate the table.

这篇关于在MySQL中获取表元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆