![]() ![]() This parameter affects the sort order of string in the queries that contain the ORDER BY clause. ![]() Specify the collation order ( LC_COLLATE) that the new database will use. By default, PostgreSQL uses the template1 database as the template database if you don’t explicitly specify the template database.ĭetermine the character set encoding in the new database. Specify the template database from which the new database is created. If you omit the OWNER option, the owner of the database is the role that you use to execute the CREATE DATABASE statement. Then, specify one or more parameters for the new database.Īssign a role that will be the owner of the database.If you try to create a database whose name already exists, PostgreSQL will issue an error. The database name must be unique in the PostgreSQL database server. First, specify the name of the new database after the CREATE DATABASE keywords. ![]() To execute the CREATE DATABASE statement you need to have a superuser role or a special CREATEDB privilege. Code language: PostgreSQL SQL dialect and PL/pgSQL ( pgsql ) The following shows the syntax of the CREATE DATABASE statement: CREATE DATABASE database_name The CREATE DATABASE statement allows you to create a new PostgreSQL database. Introduction to PostgreSQL CREATE DATABASE statement Of course, once you will add ' ' and press enter, you will get error, because, as i wrote earlier, createdb is not sql command.Summary: in this tutorial, you will learn how to use the PostgreSQL CREATE DATABASE statement to create new databases in the PostgreSQL database server. You can notice that in first line prompt ends with =#, but in second, it's -# - this - instead of = means that you are in query continuation - psql is patiently waiting for you to finish writing your query, before it will pass it to pg. ) with ' ', so psql is waiting for you to finish your query. If that's the case (there is always a chance that it was something else), then the problem is simple - you didn't end your SQL query (createdb. Within psql, you'd have to type: create database test and press enter.Ĭreatedb, on the other hand should be called from your "shell" (git bash? however it's called).Īs for your "freeze", I suspect that it didn't freeze,I suspect that your terminal looked like this: postgres=# createdb -U postgres test Reason is simple: createdb is program and not sql query.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |