ORDER BY in PostgreSQL

PostgreSQL ORDER BY PostgreSQL ORDER BY clause is used to sort or re-arrange the records in the result set. It is used with the PostgreSQL SELECT statement. It however does not have a mandatory existence with the PostgreSQL SELECT statement. Syntax: SELECT expressions FROM table_name WHERE conditions; ORDER BY expression [ ASC | DESC ]; … Read more

WHERE clause in PostgreSQL

PostgreSQL WHERE The PostgreSQL WHERE clause is used with SELECT, INSERT, UPDATE and DELETE statements to return the result only when the condition is satisfied. Syntax: WHERE conditions; Example 1: Selecting specific fields from a table. Employment table: ID STATE RATE 1 A 60 2 B 70 3 C 65 4 D 80 5 E … Read more

DELETE Query in PostgreSQL

PostgreSQL DELETE To remove or delete existing records from a table, the PostgreSQL DELETE statement is used. Syntax: To delete all rows from a table. DELETE FROM table_name; Syntax: To delete specific rows from a table. DELETE FROM table_name WHERE conditions; DELETE statement using UI: Other than Query tool, we can also DELETE statement in … Read more

UPDATE Query in PostgreSQL

PostgreSQL UPDATE To update the existing records in a table one can use the UI or can use the PostgreSQL UPDATE statement. Syntax: UPDATE table_name SET column_1 = expr_1, column_2 = expr_2, … column_n = expr_n WHERE conditions; UPDATE statement using UI: Other than Query tool, we can also UPDATE statement in PostgreSQL using UI. … Read more

SELECT Query in PostgreSQL

PostgreSQL SELECT To fetch records from a table, one can use the UI or the PostgreSQL SELECT statement can be used. SELECT statement using UI:  Other than Query tool, we can also SELECT statement in PostgreSQL using UI. To SELECT statement using UI in PostgreSQL, follow the below steps. Right-click on the selected table. Move … Read more

INSERT Query in PostgreSQL

PostgreSQL INSERT To insert new records into a table the PostgreSQL INSERT statement is used. Syntax: INSERT into table_name(column_1, column_2, … column_n ) VALUES (value_1, value_2, .. value_n); Insert statement using UI: Other than Query tool, we can also INSERT statement in PostgreSQL using UI. To INSERT statement using UI in PostgreSQL, follow the below … Read more

PostgreSQL CREATE SCHEMA

CREATE SCHEMA Creating a schema using command: Syntax: CREATE SCHEMA name; Parameters: name: It is used to specify the name of the database to be created. Example: CREATE SCHEMA students;CREATE SCHEMA students; Explanation: A new schema will be created with the name ‘students’. Creating a schema using UI: To create a schema in PostgreSQL using … Read more

PostgreSQL DROP TABLE

DROP TABLE To drop or eliminate a particular PostgreSQL table, one can use the UI or can delete or remove the PostgreSQL table using the DROP TABLE command. Syntax: DROP TABLE name; Parameters: name: It is used to specify the name of the TABLE to be dropped. Example: DROP TABLE employment;DROP TABLE employment; Explanation: The … Read more

PostgreSQL CREATE TABLE

CREATE TABLE To create a new table in a PostgreSQL database, one can use the UI or can also use the PostgreSQL CREATE TABLE statement. Syntax: CREATE TABLE table_name ( column_1 data_type column_constraint, column_2 data_type column_constraint, … ); Creating a TABLE using UI: Select the database. To get the catalogues and schema, left-click on the … Read more

PostgreSQL DROP DATABASE

DROP DATABASE To drop or eliminate a particular PostgreSQL database, one can either use the UI or can delete or remove the PostgreSQL database using the DROP database command. Syntax: DROP DATABASE name; Parameters: name: It is used to specify the name of the database to be eliminated. Example: DROP DATABASE country;DROP DATABASE country; Explanation: … Read more