Minor concern with alter table .. rename to ..

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Minor concern with alter table .. rename to ..

Olivier Mascia
Dear,

I have minor a concern with alter table .. rename to ...
Please follow this sample (3.26.0):

sqlite> create table T(A integer);
sqlite> .schema T
CREATE TABLE T(A integer);

sqlite> alter table T rename to X;
sqlite> .schema X
CREATE TABLE IF NOT EXISTS "X"(A integer);

A. Why does X needs to be escaped (" ") in the new table definition following the rename?

(Sure there is nothing wrong with that).
Though couldn't it follow the exact wording used in the rename to clause?
X if I write X and "X" if I write "X"?
To the extent that the rename could have to be refused (error return) in case of parsing issue due to the nature of the unquoted X.

B. The next question is not directly related to the rename to operation, but I spotted it when testing the rename to.

Why does "IF NOT EXISTS" is auto-added to the text of CREATE TABLE reported by the shell command .schema, when the table name was escaped in the original create statement?

sqlite> create table R(A integer);
sqlite> create table "S"(A integer);
sqlite> .schema
CREATE TABLE R(A integer);
CREATE TABLE IF NOT EXISTS "S"(A integer);

while we have this in sqlite_master:

sqlite> select * from sqlite_master;
type|name|tbl_name|rootpage|sql
table|R|R|2|CREATE TABLE R(A integer)
table|S|S|3|CREATE TABLE "S"(A integer)

Again, not bugs, merely possible discrepancies that might have a good reason to exist, though I do not yet understand why.

--
Best Regards, Meilleures salutations, Met vriendelijke groeten,
Olivier Mascia


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users