0

I need to parse an SQL name for PostgreSQL, and to be sure it is always compliant.

I know that, for example, an SQL name/identifier can even consist of a single white space.

What I'm trying to find out is - is there a single use case within the entire PostgreSQL syntax where it is possible to pass in an empty "" SQL name/identifier and still to be considered valid?

I want to know whether I should parse "" as always invalid in PostgreSQL or not.

1 Answer 1

1

An empty quoted identifier is not valid as per the SQL standard. You get the following error message when you try to create a table with "":

ERROR: zero-length delimited identifier at or near """"

And what would it identify anyways? There is no such thing like an identifier that identifies the empty identifier.


You can find out more about the syntax here: http://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html

Quoted identifiers can contain any character, except the character with code zero. (To include a double quote, write two double quotes.) This allows constructing table or column names that would otherwise not be possible, such as ones containing spaces or ampersands. The length limitation still applies.

Sign up to request clarification or add additional context in comments.

3 Comments

>And what would it identify anyways? - An empty identifier, I guess. The question was - is it something that's used anywhere in PostgreSQL?
And the answer was no.
Edited my answer to give a better explanation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.