Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
272 views
in Technique[技术] by (71.8m points)

What is a valid PostgreSQL database name?

I create a database with a hyphen in the middle of the name with createdb. That successfully creates the database, but within the psql interactive client, I get a syntax error if I try a command like this:

ALTER DATABASE my-database SET SCHEMA = myschema,public;

psql complains of a syntax error at or near "-"

Is there some documentation for what counts as a valid PostgreSQL database name?

Should I just underscores instead of hyphens?

question from:https://stackoverflow.com/questions/10216784/what-is-a-valid-postgresql-database-name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The documentation you asked about is here:

http://www.postgresql.org/docs/current/interactive/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

Most people just stick to lowercase letters, numeric digits, and underscores -- to avoid typing the quotes all the time.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...