Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that primary index is in every table #3262

Closed
AlexTr opened this issue Mar 12, 2021 · 0 comments
Closed

Make sure that primary index is in every table #3262

AlexTr opened this issue Mar 12, 2021 · 0 comments
Assignees
Milestone

Comments

@AlexTr
Copy link
Contributor

AlexTr commented Mar 12, 2021

SQL query to detect such tables:

SELECT tab.table_schema AS database_name, tab.table_name
FROM information_schema.tables tab
LEFT JOIN information_schema.table_constraints tco ON tab.table_schema = tco.table_schema
AND tab.table_name = tco.table_name
AND tco.constraint_type = 'PRIMARY KEY'
WHERE tco.constraint_type IS NULL
AND tab.table_schema NOT
IN (
'mysql', 'information_schema', 'performance_schema', 'sys'
)
AND tab.table_type = 'BASE TABLE'
AND tab.table_schema = 'mainsite_una' -- put db name here
ORDER BY tab.table_schema, tab.table_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants