DEV Community

Cover image for Introduction to Database in PostgreSQL
Kamaleshwar A
Kamaleshwar A

Posted on

Introduction to Database in PostgreSQL

In database there is SQL - Structured Query Language is standard programming language for connect with and manage the database management system.

  • Query data — retrieve specific information from a database (e.g., SELECT * FROM users)
  • Insert, update, delete data — modify records within tables
  • Define database structure — create or alter tables, set relationships between them
  • Control access — manage permissions for who can read or modify data

DBMS - DATABASE MANAGEMENT SYSTEM

A Database Management System (DBMS) is software used to manage data from a database. It acts as an interface between the database and end users or applications, ensuring data is consistently organized, easily accessible, and secure.

  • A database is a structured collection of data that is stored in an electronic device. The data can be text, video, image, or any other format.
  • A relational database stores data in the form of tables, and a NOSQL database stores data in the form of key-value pairs.
  • A DBMS is a software that allows to create, update, and retrieval of data in an organized way. It also provides security to the database.
  • Examples of relational DBMS are MySQL, Oracle, Microsoft SQL Server, PostgreSQL, and Snowflake.
  • Examples of NOSQL DBMS are MongoDB, Cassandra, DynamoDB, and Redis.

PostgreSQL

In first postgres name was ingres that is Interactive Graphic and Research. After that name is postgres.

I was learned about how to install in the linux terminal and used in terminal.

sudo apt install postgresql postgresql-contrib
Enter fullscreen mode Exit fullscreen mode

After installation open the terminal,

sudo -i -u postgres
Enter fullscreen mode Exit fullscreen mode

Here,
sudo - super user do or substitute user do
-i - start to login shell
-u - user
postgres - username.

Then put this command in your terminal

psql
Enter fullscreen mode Exit fullscreen mode

Then you have postgres shell to do practice SQL and administer the database with your terminal.

Table create:

cinemas=# create table students(stud_id int, stud_name varchar(20), course_name varchar(20));
CREATE TABLE
Enter fullscreen mode Exit fullscreen mode

Insert Values:

cinemas=# insert into students values(11, 'Vignesh', 'Java full stack'),(23, 'Kamalesh', 'Python full stack'),(15, 'Dhanush', 'Full stack'),(28, 'Madhan', 'Full stack');
INSERT 0 4

cinemas=# insert into students values(16, 'Vidhya', 'Java full stack'),(22, 'Karthick', 'Data analytics'),(24, 'Karthiga', 'Python full stack'),(32,'Saravanan', 'Mern full stack');
INSERT 0 4
Enter fullscreen mode Exit fullscreen mode

The above database are created for myself to practice and learn the SQL.

Top comments (0)