我可以在sqlite3的转义序列申报表的名称? [英] Can I declare table name with escape sequences in sqlite3?

查看:110
本文介绍了我可以在sqlite3的转义序列申报表的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能创建一个转义序列表的名字吗?
像表名:为例的

Is it possible to create a table name with escape sequences ? like TableName:exampl's

我的EditText,它是这样的条目并想创建一个表吧,没有限制的EditText上。

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.

推荐答案

是的,这是可能的。或者至少sqlite3的本身并不禁止这一点。
以下示例将创建表 tbl'1

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);

但是,

有几个原因,你不应该这样做:

There are several reasons why you should not do that:


  • 用户输入后命名的表是根本不能接受的。 ( http://xkcd.com/327/

  • 我假设你正在使用的数据库的包装,你不直接访问sqlite3的文件。如果是的话,比这个解决方案最终可能会失败。

  • 如果您有一个有效的数据库模型,也就没有需要动态创建表。 插入行新的数据,而不是。还有,只要你想,你可以使用尽可能多的转义字符。

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

这篇关于我可以在sqlite3的转义序列申报表的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆