View Full Version : Create batabase tables on the fly
RizlaUK
01-13-2007, 01:23 PM
Hi Guys, just a general sqlite question
i am wondering if its possable to let my users create tables (categories) on a single database,
like do all tables have to be created at the same time or can i add tables as and when i want to, and the same for deleteing them
or will i have to make a new database for each new categorie i want to add
RizlaUK
01-13-2007, 02:45 PM
ok, trial and error, it works, so i can create tables on the fly
but i have a new question, i need a way to get the database tablenames into a listbox, i have searched the sqlite help file but cant seem to find a answer, everything seems to point towards column names
Buffman
01-13-2007, 03:57 PM
Hi RizlaUK,
Try this, from http://www.sqlite.org/faq.html#q9:
(9) How do I list all tables/indices contained in an SQLite database?
...
Every SQLite database has an SQLITE_MASTER table that defines the schema for the database. The SQLITE_MASTER table looks like this:
CREATE TABLE sqlite_master (
type TEXT,
name TEXT,
tbl_name TEXT,
rootpage INTEGER,
sql TEXT
);
For tables, the type field will always be 'table' and the name field will be the name of the table. So to get a list of all tables in the database, use the following SELECT command:
SELECT name FROM sqlite_master
WHERE type='table'
ORDER BY name;
RizlaUK
01-13-2007, 04:31 PM
Hey Thanks, this seems pertty easy now :yes
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.