connlimit ] ] PostgreSQL Delete Database Options we can use when creating a new database with SQL command are: CREATE DATABASE name Let’s create a new database with connection limit set to 20: postgres=# CREATE DATABASE database03 OWNER geek01 CONNECTION LIMIT 20 We can also define default encoding locale, encoding, template and connection limit when creating a new database. postgres=# CREATE DATABASE database02 OWNER geek01 Please do not forget the semicolon at the end of each SQL command!Ĭreate a new database with the desired owner with the following SQL command: ~]# su - postgres The default setting for this is -1 which means unlimited number of connections can be made. These are the concurrent connections that can be made to the database. Change to “postgres” user and run “psql” to run SQL commands.Ĭreating a new database via “psql” command also allows us to define the “connection limit” for the newly created database. New PostgreSQL database can also be created via “psql” command. Psql SQL Command (PostgreSQL Create Database) You can see all available options by running “createdb –help”. We can also define locale, encoding and the template to use when creating a new database. In this example we created a new database called “database01” with owner “geek01” – of course this PostgreSQL user must exist.Īnother useful option when using “createdb” is the “echo” of the SQL command sent by the “createdb” command: -bash-4.1$ createdb -O geek01 database01 -e In most cases the following syntax will be more than enough when creating a new PostgreSQL database: ~]# su - postgres Interesting thing is also that by default new databases will be created by cloning the standard system database “template1”. We can create a new PostgreSQL database using the console command “createdb” which we must run as “postgres” user.Īlthough console comand “createdb” is a wrapper around SQL “CREATE DATABASE” command, it does not support setting a “connenction limit” for the newly created database.īy default, if no database name is specified, a new database with the same name as the user running “createdb” command will be created. Console Command (PostgreSQL Create Database) This is important since by default authentication for local users is set to peer and enables “postgres” user to login via “ psql” without any password prompt. We are assuming you are running a fresh and clean install of PostgreSQL server and did not touch “ph_dba.conf” file yet.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |