I’m trying to accomplish something like this:
SELECT *
FROM information_schema.`tables`
JOIN (SHOW CREATE TABLE) # <-- need help here
WHERE table_schema LIKE 'tables\_%'
Is there a way to do this in one query?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Devart is correct that you can’t join to the
SHOW CREATEstatement.However, depending on your exact needs, you can spoof this by creating your own
SHOW CREATEstatement.The complexity of the code will increase if you need to include the database engine, column and table collations, indexes, and so forth – however the SQL below will give you the right table and fields, complete with datatypes. I’m sure you can extend it further by examining the contents of
information_schema.columnsin more depth.Sample output: