Skip to content Skip to sidebar Skip to footer

Can I Declare Table Name With Escape Sequences In Sqlite3?

Is it possible to create a table name with escape sequences ? like TableName:exampl's I have EditText and it's entry like that and want to create a table for it ,and there is no r

Solution 1:

Yes, it is possible. Or at least sqlite3 itself does not forbid this. The following example would create the table tbl'1

createtable "tbl'1"(onevarchar(10), two smallint);

But.

There are several reasons why you should not do that:

  • Naming tables after user input is simply not acceptable. (http://xkcd.com/327/)
  • I assume that you are using a database wrapper and you do not directly access the sqlite3 file. If yes, than this solution may fail eventually.
  • If you have a valid database model, there will be no need to create tables dynamically. Insert rows for new data instead. There you can use as much escape characters as you want.

Post a Comment for "Can I Declare Table Name With Escape Sequences In Sqlite3?"