The output indicates that the table has been created. Third, input the CREATE TABLE statement and press Enter: CREATE TABLE accounts ( Second, connect to the dvdrental database: \c dvdrental When you enter a password correctly, you’ll see the following command prompt: postgres= # Code language: PHP ( php ) It’ll prompt you to enter a password for the user postgres. We’ll show you step-by-step how to create the accounts table using the psql client tool.įirst, open the Command Prompt on Windows or Terminal on Unix-like systems and connect to the PostgreSQL: psql -U postgres To create a table in a database, you need to execute the CREATE TABLE statement using a PostgreSQL client such as psql and pgAdmin. The following example uses the CREATE TABLE statement to create the accounts table: CREATE TABLE accounts ( The accounts table has the following columns: We will create a new table called accounts in the dvdrental sample database. Table constraints are similar to column constraints except that you can include more than one column in the table constraint. Unlike the primary key, a table can have many foreign keys.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |