If specified, the data in the table is not recorded in the pre-recording log. If one of them is specified, the table is a local time table. If one of them is specified, the table is a global time table. ]Ĭonsider the PostgreSQL example CREATE TABLE. REFERENCES another_table_name (index_col_name.) However, the full syntax for the CREATE TABLE statement in PostgreSQL: To delete tables, the DROP TABLE command is used, which has the following syntax: stores the numbers.Īnd after running this command, a table of customers will be added to the selected database. The last column Age represents the user age and is of type INTEGER, i.e. they represent a line no longer than 30 characters long. The next three columns represent the client’s name, surname and email address and are CHARACTER VARYING(30) type, i.e. In fact, this column will store a numerical value of 1, 2, 3, etc., which for each new row will automatically increase by one. The first column – Id represents the client ID, it serves as the primary key and therefore is of SERIAL type. In this case the Customers table defines five columns: Id, FirstName, LastName, Age, Email. Then in the field opened in the central part of the program we will enter the following set of expressions: And the table will be created exactly for the database for which we open this field for entering SQL. To do this, first select the target database in pgAdmin, right-click on it and select Query Tool in the context menu…:Īfter that a field for SQL code input will open. The data type determines what data (numbers, rows, etc.) the column can contain.įor example, let’s create a table in the database via pgAdmin. And for each column you should specify the name and data type it will represent. Name_columnN type_data attribute_columnN,Īfter the table name, the specification for all columns is listed in brackets. (column_name1 type_data attribute_column1, The simplest syntax for the CREATE TABLE statement in PostgreSQL: PostgreSQL operator CREATE TABLE allows you to create and define a table Creating database and table with PostgreSQL (pgAdmin)
0 Comments
Leave a Reply. |