blog image

in this tutorial we will learn about postgresql database.

PostgreSQL, which is a powerful open-source relational database management system (RDBMS). PostgreSQL is known for its reliability, robustness, and support for advanced features.

  1. Installation:

    • You can install PostgreSQL on various operating systems including Linux, macOS, and Windows.
    • You can download the installation files from the official PostgreSQL website: https://www.postgresql.org/download/.
  2. Setup:

    • During installation, PostgreSQL will prompt you to set a password for the default database superuser (postgres). Remember this password as it's crucial for managing your PostgreSQL installation.
    • After installation, ensure that the PostgreSQL service is running.

 

Command Line Tools:

  • PostgreSQL provides command-line tools for database administration and management. The primary tool is psql, which is a terminal-based front end to PostgreSQL.
  • You can access psql by opening your terminal/command prompt and typing psql.

 

 

Other information related to postgesql

SQL:

  • SQL (Structured Query Language) is the language used to interact with relational databases.
  • Learn SQL syntax, including how to create databases, tables, insert data, retrieve data using SELECT statements, update and delete data, and perform basic aggregation functions.
  • There are many online resources and tutorials available to learn SQL.

 

Data Types:

  • PostgreSQL supports various data types such as integer, text, varchar, date, timestamp, boolean, etc. Familiarize yourself with these data types and their usage.

 

Constraints:

  • PostgreSQL allows you to enforce data integrity using constraints such as NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK, etc.

 

Indexes:

  • Indexes are used to improve the performance of database queries. Learn how to create indexes on tables based on your query patterns.

 

Transactions and Concurrency:

  • Understand the concepts of transactions, isolation levels, and concurrency control in PostgreSQL.

 

Advanced Features:

  • Once you're comfortable with the basics, explore advanced features such as stored procedures, triggers, views, user-defined types, and user-defined functions.

 

 

some postgresql commands:

sudo su postgres
[sudo] password for user: 

OR 

sudo -i -u postgres

psql

psql -U username -d database_name  # connect t database with username

\l   #to see all databases
\c database_name   # switch to different db
\dt      # to get list of table
\d table_name      # describe table

\du   # to see all the database users and roles

or 

SELECT * FROM pg_catalog.pg_roles;

drop user user_name or drop role user_name;  # to delete the user 


create user odoo superuser; #to create odoo as user  which have all access right 
alter user odoo with password 'odoo';



psql -U postgres_username  -h database_host -p port_number    # to connect to server database

psql -U postgres_username -d database_name -h database_ip_address -p post_number  # connect server 


psql -U ncell -d ncell;
psql -U postgres;


sudo systemctl start postgresql.service


#to move local file to database
psql -U username -d data_base_name -f local_database_file.sql;


#to downlaod server database file to local
\! pg_dump -U postgres_devsecops -h 10.18.12.121 -p 5532 -d ncell > ncell_dump.sql


create user ncell with password 'ncell';

SELECT rolname FROM pg_roles;

 


About author

author image

Amrit Panta

Python developer, content writer



3 Comments

Amanda Martines 5 days ago

Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.

Reply

Baltej Singh 5 days ago

Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Marie Johnson 5 days ago

Kickstarter seitan retro. Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Leave a Reply

Scroll to Top