You should NOT be storing the name of a stock as the table name. This is THE prime example of how NOT to do things. Instead of CREATE TABLE stock_xyz(date unique, ...); do something like CREATE TABLE stocks (stockID INTEGER PRIMARY KEY, short TEXT, long TEXT); CREATE TABLE ticker (stockID INTEGER REFERENCES stocks(stockID), date, ..., unique(stockID,date)); Then you will always be inserting into ticker using the stockID read from table stocks. To simplify selecting, you can create a view CREATE VIEW stock_ticker AS SELECT s.short,s.long,t.date [,...] FROM stocks s JOIN ticker t ON s.stock_ID=t.stockID; So that you can refer to stocks via short or long name.