开发者

Can I declare table name with escape sequences in sqlite3?

Is it possible to create a table name with escape sequences ?开发者_JS百科 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.


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜