List the columns explicitly : Insert « Insert Delete Update « PostgreSQL






List the columns explicitly

postgres=# CREATE TABLE products (
postgres(#    product_no integer,
postgres(#    name text,
postgres(#    price numeric
postgres(# );
CREATE TABLE
postgres=# -- List the columns explicitly
postgres=#
postgres=# INSERT INTO products (product_no, name, price) VALUES (1, 'Cheese', 9.99);
INSERT 0 1
postgres=# INSERT INTO products (name, price, product_no) VALUES ('Cheese', 9.99, 1);
INSERT 0 1
postgres=#
postgres=#
postgres=# select * from products;
 product_no |  name  | price
------------+--------+-------
          1 | Cheese |  9.99
          1 | Cheese |  9.99
(2 rows)

postgres=#
postgres=# drop table products;
DROP TABLE
postgres=#
postgres=#
postgres=#

           
       








Related examples in the same category

1.The data values are listed in the order in which the columns appear in the table, separated by commas
2.Omit values
3.Fill the columns from the left with as many values as are given, and the rest will be defaulted
4.Request default values explicitly, for individual columns
5.Request default values explicitly for the entire row
6.Insert date data to table
7.Inserts a single row into the employees table
8.Insert only an ID: only one column