views:

39

answers:

1

Hi folks,

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?

+3  A: 

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 
Madhivanan
@Madhivanan Thanks that worked!
RadiantHex
You are welcome
Madhivanan