Reputation: 48871
I can't decide if this is a dumb question or not but I'll take the risk. :)
I'm a fairly simple SQL user - I understand CREATE/DROP tables and SELECT, INSERT, DELETE in their basic forms but not much more. What I'd like to know is if there's a way with SQL to request the schema of a table?
I have a PC app which uses SQLite and I'm writing a mobile client for it. I don't need all of the tables from the PC DB and not all columns from the tables. In SQLite Spy, I can right-click a table and select 'Show CREATE statement' which generates the SQL needed to recreate the table.
What I'd like to do (using code on the PC) to get the CREATE statement (or at least the schema) of the SQLite tables I need and then edit the strings to include only the columns I need. These could then be passed to my mobile app so it could create the 'subset' DB on the device. Is it possible?
EDIT: For anyone who comes after me looking for a similar answer. Thanks to dan04 pointing me in the right direction. The results of using...
SELECT * FROM sqlite_master
... include a column called 'sql' which includes the CREATE statement. Just what I'm looking for. :)
Upvotes: 8
Views: 9018