Skip to main content


Showing posts from June, 2019

Select Query in PostgreSQL

In this tutorial, you will learn how to query basic data using the original PostgreSQL SELECT selection statement. SELECT keywords are most commonly used in PostgreSQL to fetch records from the table, selection statement is very sophisticated statements to PostgreSQL regarding performance so use the SELECT statements with accuracy. PostgreSQL selection details is deployed to obtain data from the database table, which is returning the data in the form of results table. These result tables are called result-sets. Syntax for SELECT statements:
SELECT column1, column2, columnN FROM table_name;

Here, column 1, column 2 is the fields of ​​a table whose value you want to receive. If you want to access all the fields in the result set then you can apply the following syntax –
SELECT * FROM table_name;

INSERT data into table in PostgreSQL

The PostgreSQL INSERT INTO statement assures you to include a new row in the table. A row or multiple rows can be inserted at the time of the query results. Syntax to use of INSERT INTO keyword in PostgreSQLThe original sentence of INSERT INTO statement is as follows:
INSERT INTO TABLE_NAME (column1, column2, column3,...columnN) VALUES (value1, value2, value3,...valueN);

Here, column 1, column 2, columns are columns in the table in which you want to insert the data. The names of the target column can be listed in any order. The value given by the price segment or the query is linked to the left or right from a clear or built-in column list. If you are adding values ​​to all the columns in the table, you may not need to specify the column (s) in the SQL query. However, undo doubt that the order of values ​​is in the same table in the table. The SQL INSERT INTO syntax will be as follows-
INSERT INTO TABLE_NAME VALUES (value1,value2,value3,...valueN);
Output explanation when Inserted records…

Schema in PostgreSQL

Name of the Schema table is accumulation. A schema can also have thoughts, indexes, sequences, data types, operators, and functions. Schema corresponds to the directories at the operating system level, apart from that the schema cannot be nested. PostgreSQL statement Creation schema creates a schema. Syntax:Here is the original syntax of the CREATE schema: CREATE SCHEMA name; Syntax for schematic tableHere is the basic syntax for creating tables in schema: CREATE TABLE <schema name>.<Table Name>(Column1 int null, …); Illustration Let's see an illustration for creating schemas. Link to database testing and create a schema schema1 that is as follows – create schema schema1; The message "Building schema" indicates that the schema has been created successfully. Now, create a table in the above schema, which is as follows – create table schema1.table1(    ID   INTEGER  NOT NULL,    NAME CHARACTER VARYING (50)  NOT NULL,    DOJ  TIMESTAMP WITH TIME ZONE NOT NULL,    ADDRESS…