Author: admin

  • ORDER BY Clause

    The PostgreSQL ORDER BY clause is used to sort the data in ascending or descending order, based on one or more columns. Syntax The basic syntax of ORDER BY clause is as follows −SELECT column-list FROM table_name [WHERE condition] [ORDER BY column1, column2, .. columnN] [ASC | DESC]; You can use more than one column in the…

  • LIMIT Clause

    The PostgreSQL LIMIT clause is used to limit the data amount returned by the SELECT statement. Syntax The basic syntax of SELECT statement with LIMIT clause is as follows − The following is the syntax of LIMIT clause when it is used along with OFFSET clause − LIMIT and OFFSET allow you to retrieve just a portion…

  • LIKE Clause

    The PostgreSQL LIKE operator is used to match text values against a pattern using wildcards. If the search expression can be matched to the pattern expression, the LIKE operator will return true, which is 1. There are two wildcards used in conjunction with the LIKE operator − The percent sign represents zero, one, or multiple numbers or characters.…

  • DELETE Query

    The PostgreSQL DELETE Query is used to delete the existing records from a table. You can use WHERE clause with DELETE query to delete the selected rows. Otherwise, all the records would be deleted. Syntax You can combine N number of conditions using AND or OR operators. Example The following is an example, which would DELETE a…

  • UPDATE Query

    The PostgreSQL UPDATE Query is used to modify the existing records in a table. You can use WHERE clause with UPDATE query to update the selected rows. Otherwise, all the rows would be updated. Syntax You can combine N number of conditions using AND or OR operators. Example The following is an example, which would update ADDRESS…

  • SELECT Query

    PostgreSQL SELECT statement is used to fetch the data from a database table, which returns data in the form of result table. These result tables are called result-sets. Syntax Here, column1, column2…are the fields of a table, whose values you want to fetch. If you want to fetch all the fields available in the field then you…

  • INSERT Query

    The PostgreSQL INSERT INTO statement allows one to insert new rows into a table. One can insert a single row at a time or several rows as a result of a query. Syntax You may not need to specify the column(s) name in the SQL query if you are adding values for all the columns of the…

  • Schema

    A schema is a named collection of tables. A schema can also contain views, indexes, sequences, data types, operators, and functions. Schemas are analogous to directories at the operating system level, except that schemas cannot be nested. PostgreSQL statement CREATE SCHEMA creates a schema. Syntax The basic syntax of CREATE SCHEMA is as follows −CREATE SCHEMA name;…

  • CREATE Table

    The PostgreSQL CREATE TABLE statement is used to create a new table in any of the given database. Syntax Basic syntax of CREATE TABLE statement is as follows −CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, ….. columnN datatype, PRIMARY KEY( one or more columns ) ); CREATE TABLE is a keyword, telling the…

  • SELECT Database

    This chapter explains various methods of accessing the database. Assume that we have already created a database in our previous chapter. You can select the database using either of the following methods − Database SQL Prompt Assume you have already launched your PostgreSQL client and you have landed at the following SQL prompt −postgres=# OS…