MySQL && OpenGauss 表元数据查询总结

本文总结了在MySQL和OpenGauss中查询表元数据的差异。在MySQL中,用户可以通过information_schema库的tables和columns表获取表信息和字段信息。而在OpenGauss中,由于没有直接对应的查询方式,需要利用提供的视图来组合SQL进行查询。
摘要由CSDN通过智能技术生成

在MYSQL中,查询用户表信息和表字段信息,在mysql的 information_schema库中tables 表和columns表中进行定义,我们可以直接查询。

select table_name tableName , table_rows tableRows from information_schema.tables  WHERE table_schema=?
select table_name tableName ,column_name  columnName, ordinal_position ordinalPosition, data_type dataType, column_type columnType,column_key columnKey from information_schema.columns where table_name in (:tableNames)

但是在OpenGauss中,我们不能直接查询这些信息,需要根据openGauss提供的一些视图自己组装SQL

information_schema.tables 表信息

information_schema.columns 表列信息

information_schema.key_column_usage 约束对应字段信息

information_schema.table_constraints 表约束信息

select table_name tableName  from information_schema.tables  WHERE  table_schema=? and TABLE_TYPE='BASE TABLE';
selec
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

仰望星空@脚踏实地

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值