SQLite Table Name: name syntax ?

Stupid question I get when I awoke earlier today:

is there’s a syntax for the TABLE Name (CREATE TABLE ) ?

In other words, can I create a TABLE NAME between quotes ?

ex.: CREATE TABLE “Marketing Table”

Or… CREATE TABLE “Invoice Date” ?

As soon as I send the new conversation text, I found an answer in a Microsoft SQL web page… I have to read a little more.

… then you can share the answer here :slight_smile:

Hi Joost,

in fact, I trashed the page (I was not able to read it, I was thinking at something else, then I could not read the text).

After a second search, I found:

here

a page about Identificateur de la base de donnes (Data base identifiers ?). Stupid web (or Microsoft: I coumd not get the page in us-en nor en-en)

In fact, and after 2 hours, I realized that the Table syntax was not the only question: I also wanted to know about the Column_Name syntax.

Some things are harder to find than others and the quality of that thing is not involved (answers for easy thing or hard to understand things can be hard to find) ;-:slight_smile:

I hope this is the answer to the question.

I tried and it works:

CREATE TABLE [My Friends] ( pk INTEGER PRIMARY KEY, fname TEXT, [Last Name] TEXT);

also tried

CREATE TABLE "My Friends" ( pk INTEGER PRIMARY KEY, fname TEXT, "Last Name" TEXT);

and it worked.

For tablenames I normally use the brackets…

I use single quote and it worked for me.

I never use spaces in table names and that always works either way in every database :stuck_out_tongue:

That’s best practice… I agree.
Last week I wrote a method to auto build a sqlite database from another data-source. In this case you must make sure no space in names will hit you in create-queries.

Joost, all:

I wanted to make (more) tests yesterday afternoon, but I got troubles (nap ? phone call ? visits ? I forgot).
But, I never tested these creative ways to pass a TABLE name.

In my previous tests (month ago), using the ListBox Heading as TABLE NAME (as is: no quote / bracket / whatever), SQLite was Crying in the Chapel (complaining).

I built a “Create a SQLite Data Base” window yesterday before the interrupt that let the user type its own Column Identifier for each Heading string. I didn’t had time to write the code, onl the design.

The base idea is… something like what Joost said: auto build from an external source (or | and internal source too). Anyone can want to create a db from txt, csv, json, whatever external source can be (even if you (I) created the file first !