Top tutorials to learn postgresql database for beginners free năm 2024

Welcome to the PostgreSQLTutorial.com website! This PostgreSQL tutorial helps you understand PostgreSQL quickly. You’ll master PostgreSQL very fast through many practical examples and apply the knowledge in developing applications using PostgreSQL.

If you are…

  • Looking to learn PostgreSQL fast.
  • Developing applications using PostgreSQL as the back-end database management system.
  • Migrating from other database management systems such as MySQL, Oracle, and Microsoft SQL Server to PostgreSQL.

You’ll find all you need to know to get started with PostgreSQL quickly and effectively here on this website.

PostgreSQL tutorial demonstrates many unique features of PostgreSQL that make it the most advanced open-source database management system.

Getting Started with PostgreSQL

This section helps you get started with PostgreSQL by showing you how to install PostgreSQL on Windows, Linux, and macOS. You also learn how to connect to PostgreSQL using the psql tool as well as how to load a sample database into the PostgreSQL for practicing.

First, you’ll learn how to query data from a single table using basic data querying techniques, which include selecting data, sorting result sets, and filtering rows.

Then, you’ll learn about advanced queries such as joining multiple tables, using set operations, and constructing the subquery.

Finally, you will learn how to manage database tables, such as creating a new table or modifying an existing table’s structure.

Section 1. Querying Data

  • Select – show you how to query data from a single table.
  • Column aliases – learn how to assign temporary names to columns or expressions in a query.
  • Order By – guide you on how to sort the result set returned from a query.
  • Select Distinct – provide you with a clause that removes duplicate rows in the result set.

Section 2. Filtering Data

  • Where – filter rows based on a specified condition.
  • Limit – get a subset of rows generated by a query.
  • Fetch– limit the number of rows returned by a query.
  • In – select data that matches any value in a list of values.
  • Between – select data that is a range of values.
  • Like – filter data based on pattern matching.
  • Is Null – check if a value is null or not.

Section 3. Joining Multiple Tables

  • Joins – show you a brief overview of joins in PostgreSQL.
  • Table aliases – describes how to use table aliases in the query.
  • Inner Join – select rows from one table that have the corresponding rows in other tables.
  • Left Join – select rows from one table that may or may not have the corresponding rows in other tables.
  • Self-join – join a table to itself by comparing a table to itself.
  • Full Outer Join – use the full join to find a row in a table that does not have a matching row in another table.
  • Cross Join – produce a Cartesian product of the rows in two or more tables.
  • Natural Join – join two or more tables using implicit join conditions based on the common column names in the joined tables.

Section 4. Grouping Data

  • Group By – divide rows into groups and apply an aggregate function on each.
  • Having – apply conditions to groups.

Section 5. Set Operations

  • Union – combine result sets of multiple queries into a single result set.
  • Intersect – combine the result sets of two or more queries and returns a single result set that has the rows appear in both result sets.
  • Except – return the rows in the first query that does not appear in the output of the second query.

Section 6. Grouping sets, Cube, and Rollup

  • Grouping Sets – generate multiple grouping sets in reporting.
  • Cube – define multiple grouping sets that include all possible combinations of dimensions.
  • Rollup – generate reports that contain totals and subtotals.

Section 7. Subquery

  • Subquery – write a query nested inside another query.
  • ANY – retrieve data by comparing a value with a set of values returned by a subquery.
  • ALL – query data by comparing a value with a list of values returned by a subquery.
  • EXISTS – check for the existence of rows returned by a subquery.

Section 8. Common Table Expressions

  • PostgreSQL CTE – introduce you to PostgreSQL common table expressions or CTEs.
  • Recursive query using CTEs – discuss the recursive query and learn how to apply it in various contexts.

Section 9. Modifying Data

In this section, you will learn how to insert data into a table with the INSERT `statement, modify existing data with the `UPDATE statement, and remove data with the DELETE statement. Besides, you learn how to use the upsert statement to merge data.

  • Insert – guide you on how to insert a single row into a table.
  • Insert multiple rows – show you how to insert multiple rows into a table.
  • Update – update existing data in a table.
  • Update join – update values in a table based on values in another table.
  • Delete – delete data in a table.
  • Upsert – insert or update data if the new row already exists in the table.

Section 10. Transactions

  • PostgreSQL Transactions – show you how to handle transactions in PostgreSQL using BEGIN, COMMIT, and ROLLBACK statements.

Section 12. Managing Tables

In this section, you will start exploring the PostgreSQL data types and show you how to create new tables and modify the structure of the existing tables.

  • Data types – cover the most commonly used PostgreSQL data types.
  • Create a table – guide you on how to create a new table in the database.
  • Select Into & Create table as– shows you how to create a new table from the result set of a query.
  • Auto-increment column with SERIAL – uses SERIAL to add an auto-increment column to a table.
  • Sequences – introduce you to sequences and describe how to use a sequence to generate a sequence of numbers.
  • Identity column – show you how to use the identity column.
  • Alter table – modify the structure of an existing table.
  • Rename table – change the name of the table to a new one.
  • Add column – show you how to add one or more columns to an existing table.
  • Drop column – demonstrate how to drop a column of a table.
  • Change column data type – show you how to change the data of a column.
  • Rename column – illustrate how to rename one or more columns of a table.
  • Drop table – remove an existing table and all of its dependent objects.
  • Truncate table – remove all data in a large table quickly and efficiently.
  • Temporary table – show you how to use the temporary table.
  • Copy a table – show you how to copy a table to a new one.

Section 13. Understanding PostgreSQL Constraints

  • Primary key – illustrate how to define a primary key when creating a table or adding a primary key to an existing table.
  • Foreign key – show you how to define foreign key constraints when creating a new table or add foreign key constraints for existing tables.
  • CHECK constraint – add logic to check value based on a Boolean expression.
  • UNIQUE constraint – make sure that values in a column or a group of columns are unique across the table.
  • NOT NULL constraint – ensure values in a column are not NULL.

Section 14. PostgreSQL Data Types in Depth

  • Boolean – store TRUE and `FALSE `values with the Boolean data type.
  • CHAR, VARCHAR and TEXT – learn how to use various character types including CHAR, VARCHAR, and TEXT.
  • NUMERIC – show you how to use NUMERIC type to store values that precision is required.
  • Integer – introduce you to various integer types in PostgreSQL including `UPDATE`0, `UPDATE`1 and `UPDATE`2.
  • DATE – introduce the `UPDATE`3 data type for storing date values.
  • Timestamp – understand timestamp data types quickly.
  • Interval – show you how to use interval data type to handle a period effectively.
  • TIME – use the `UPDATE`4 datatype to manage the time of day values.
  • UUID – guide you on how to use `UPDATE`5 datatype and how to generate `UPDATE`5 values using supplied modules.
  • Array – show you how to work with the array and introduces you to some handy functions for array manipulation.
  • hstore – introduce you to data type which is a set of key/value pairs stored in a single value in PostgreSQL.
  • JSON – illustrate how to work with JSON data type and shows you how to use some of the most important JSON operators and functions.
  • User-defined data types – show you how to use the `UPDATE`7 and `UPDATE`8 statements to create user-defined data types.

Section 15. Conditional Expressions & Operators

  • `UPDATE`9 – show you how to form conditional queries with `UPDATE`9 expression.
  • DELETE`1 – return the first non-null argument. You can use it to substitute `NULL by a default value.
  • DELETE`3 – return `NULL if the first argument equals the second one.
  • `DELETE`5 – convert from one data type into another e.g., from a string into an integer, from a string into a date.

Section 16. PostgreSQL Utilities

  • psql commands – show you the most common psql commands that help you interact with psql faster and more effectively.

Section 17. PostgreSQL Recipes

  • How to compare two tables – describe how to compare data in two tables in a database.
  • How to delete duplicate rows in PostgreSQL – show you various ways to delete duplicate rows from a table.
  • How to generate a random number in a range – illustrate how to generate a random number in a specific range.
  • EXPLAIN statement– guide you on how to use the `DELETE`6 statement to return the execution plan of a query.
  • PostgreSQL vs. MySQL – compare PostgreSQL with MySQL in terms of functionalities.

Advanced PostgreSQL Tutorial

This advanced PostgreSQL tutorial covers the advanced concepts including stored procedures, indexes, views, triggers, and database administrations.

PostgreSQL PL/pgSQL

This PostgreSQL stored procedures section shows you step by step how to develop PostgreSQL user-defined functions using PL/pgSQL procedural language.

PostgreSQL Triggers

This section provides you with PostgreSQL trigger concept and shows how to manage triggers in PostgreSQL.

PostgreSQL Views

We will introduce you to the database views concept and show you how to manage views such as create, alter, and remove views from the database.

PostgreSQL Indexes

PostgreSQL indexes are effective tools to enhance database performance. Indexes help the database server find specific rows much faster than it could do without indexes.

PostgreSQL Administration

PostgreSQL administration covers the most important activities for PostgreSQL database server including roles and databases management, backup and restore.

How do I start learning PostgreSQL?

Basics.

Install PostgreSQL..

Connect to PostgreSQL DB..

Create Database in PostgreSQL..

Create Table in PostgreSQL Database..

Copy Table..

Drop Table in PostgreSQL Database..

Drop Database in PostgreSQL..

Truncate Table in PostgreSQL..

How many days it will take to learn PostgreSQL?

If you have some prior experience in designing and building databases, one to two weeks of dedication should be sufficient to master the concepts of PostgreSQL. If not, you can expect a time of two to three weeks to cover the topics in all its depth.

Is PostgreSQL good for beginners?

It's still the most advanced open-source RDBMS in the world. And it's an excellent choice for those who are new to SQL. Out of 6 members asked, 5 answered they would recommend PostgreSQL for starting to learn SQL!

Can I learn PostgreSQL without SQL?

For administration tasks you need to know SQL and have ability with the operating system running PostgreSQL. At some point during your progression you will start needing to automate tasks. So learn a little of stored procedures and triggers, so you will need to learn pgpsql.