0

I'm trying to accomplish the following:

  • Grab the db schema

  • Grab any constraints*

  • Alter tables

  • Add/Drop tables

I'm currently using pyodbc backend for Django.

I would like to perform all these tasks within a view file.


I'm using the following in order to grab fields of tables starting with 'core_':

SELECT  table_name,ordinal_position,column_name,data_type,
is_nullable,character_maximum_length FROM
information_schema.COLUMNS WHERE table_name LIKE 'core_%'
ORDER BY ordinal_position

*Fixed thanks to Madhivanan Link


Any ideas to get started?

1 Answer 1

3

Try this by using a wildcard %

SELECT  table_name,ordinal_position,column_name,data_type, 
is_nullable,character_maximum_length FROM 
information_schema.COLUMNS WHERE table_name LIKE 'core_%' 
ORDER BY ordinal_position 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.