What are the combination of characters for a table name in SQLite to be valid? Are all combinations of alphanumerics (A-Z, a-z and 0-9) constitute a valid name?
Ex. CREATE TABLE 123abc(...);
What about a combination of alphanumerics with dashes "-" and periods ".", is that valid as well?
Ex. CREATE TABLE 123abc.txt(...); Ex. CREATE TABLE 123abc-ABC.txt(...);
Thank you.
Table names can contain any valid characters (for example, spaces). If table names contain any characters except letters, numbers, and underscores, the name must be delimited by enclosing it in back quotes (`).
To rename a table, the SQLite ALTER TABLE syntax is: ALTER TABLE table_name RENAME TO new_table_name; table_name. The table to rename.
Table names must follow the rules for SQL Server identifiers, and be less than 128 characters. It is possible to force SQL Server to accept non-standard table names by surrounding them with square brackets but it is a very bad idea, because they have to be 'quoted' whenever they are used in scripts.
Introduction. Every SQLite database contains a single "schema table" that stores the schema for that database. The schema for a database is a description of all of the other tables, indexes, triggers, and views that are contained within the database.
I haven't found a reference for it, but table names that are valid without using brackets around them should be any alphanumeric combination that doesn't start with a digit:
abc123 - valid 123abc - not valid abc_123 - valid _123abc - valid abc-abc - not valid (looks like an expression) abc.abc - not valid (looks like a database.table notation)
With brackets you should be able to use pretty much anything as a table name:
[This should-be a_valid.table+name!?]
All of these are allowed, but you may have to quote them in ""
.
sqlite> CREATE TABLE "123abc"(col); sqlite> CREATE TABLE "123abc.txt"(col); sqlite> CREATE TABLE "123abc-ABC.txt"(col); sqlite> select tbl_name from sqlite_master; 123abc 123abc.txt 123abc-ABC.txt
In general, though, you should stick to the alphabet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With