Ramesh Akula
Ramesh Akula

Reputation: 5750

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 restriction for the edittext.

Upvotes: 2

Views: 214

Answers (1)

Sebastian Hojas
Sebastian Hojas

Reputation: 4210

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

create table "tbl'1"(one varchar(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.

Upvotes: 1

Related Questions