嗨, 大家好: 网站在新年后正式开通,欢迎大家加入我们,共同维护一个良好氛围的中国技术社区。 欢迎举报不良帖子,欢迎提供建议。
我们的QQ群:136102234,欢迎进群找答案,里边会有很多资深的大师们。 point overflow

null是表示什么都没有,针对索引的时候,也是不计算到索引里边的。所以主键和唯一索引就失效了。

那这时候就需要一个语句来查询相关表的情况。

asked 2017-05-25 17:20:27

jkant's gravatar image

jkant ♦♦
11134138139
accept rate: 3%


select tc.TABLE_SCHEMA,tc.TABLE_NAME,tc.CONSTRAINT_NAME,c.COLUMN_NAME,c.IS_NULLABLE from information_schema.TABLE_CONSTRAINTS tc join information_schema.STATISTICS s on s.INDEX_NAME=tc.CONSTRAINT_NAME and tc.table_name=s.TABLE_NAME and tc.table_schema=s.TABLE_SCHEMA join information_schema.columns c on s.COLUMN_NAME=c.COLUMN_NAME and s.table_name=c.TABLE_NAME and c.table_schema=s.TABLE_SCHEMA where CONSTRAINT_TYPE in('PRIMARY KEY','UNIQUE') and c.column_type in('date','datetime','time','timestamp') and tc.TABLE_SCHEMA='x' limit 10

link

answered 2017-05-25 17:20:32

jkant's gravatar image

jkant ♦♦
11134138139
accept rate: 3%

已编辑 2017-05-25 17:20:51

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×72
×3
×1
×1

Asked: 2017-05-25 17:20:27

Seen: 1,392 times

Last updated: 2017-05-25 17:20:51