Difference between revisions of "PostgreSQL-Database/C2/Creating-a-Database-using-a-Terminal/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Title of the script''':''' Creating a Database using a terminal''' '''Author''':''' EduPyramids''' '''Keywords''': RDBMS, PostgreSQL, pgAdmin, Database, table, field, re...")
 
 
Line 54: Line 54:
  
  
The following code file is required to practice this tutorial.* cd-commands.txt
+
The following code file is required to practice this tutorial.
 +
 
 +
* cd-commands.txt
  
 
This file is provided in the code files link of this tutorial page.
 
This file is provided in the code files link of this tutorial page.
Line 95: Line 97:
 
|-  
 
|-  
 
|| Type''' p s q l'''
 
|| Type''' p s q l'''
|| To Access '''p s q l''' prompt.Type '''p s q l''' and press '''Enter'''.  
+
|| To Access '''p s q l''' prompt.
 +
 
 +
Type '''p s q l''' and press '''Enter'''.  
 
|-  
 
|-  
 
|| '''psql prompt displayed'''
 
|| '''psql prompt displayed'''

Latest revision as of 11:59, 6 February 2026

Title of the script: Creating a Database using a terminal


Author: EduPyramids

Keywords: RDBMS, PostgreSQL, pgAdmin, Database, table, field, record, EduPyramids, video tutorial.


Visual Cue Narration
Slide 1

Title Slide

Welcome to the Spoken Tutorial on Creating a Database using a Terminal.
Slide 2

Learning Objectives

In this tutorial we will learn to,
  • Log in to the Linux terminal.
  • Switch to postgres user.
  • Access p s q l prompt.
  • Create a database using S Q L.


Slide 3

System Requirements

To record this tutorial, I am using
  • Ubuntu 24 point 04 L T S and
  • Post gres Q L version 18 point 1 .


Slide 4

Pre-requisites


https://EduPyramids.org

To follow this tutorial,
  • Learners should be familiar with Linux terminal.
  • For the pre-requisite Post gres Q L tutorials, please visit this website.
Slide 5

Code Files


The following code file is required to practice this tutorial.

  • cd-commands.txt

This file is provided in the code files link of this tutorial page.

The following code file is required to practise this tutorial.


This file is provided in the Code Files link of this tutorial page.

Press Ctrl, Alt and T keys together. Let us open the terminal.
Terminal window displayed We will create a database using Post gres Q L C L I.
Type: sudo systemctl status postgresqlPress Enter.

Type the system password to authenticate.

Type sudo space system c t l space status space post gres q l and press Enter.

If prompted type the admin password to authenticate.

Point to the displayed output:

Highlight output: Active: acitve

The Post gres Q L service status is now displayed.


Notice that the service is active.

Press q to exit. Press q to exit from the status.
Type: sudo -i -u postgresPress Enter. Type the following command to switch to the postgres user and press Enter.
Highlight:

postgres@spoken-Latitude-3480:~$

Notice that we are logged in as postgres user.
Type p s q l To Access p s q l prompt.

Type p s q l and press Enter.

psql prompt displayed

Highlight postgres=#

This is the Post gres Q L interactive terminal.

Observe that prompt changes into postgres equal to hash.

Type \l To list all the existing databases type backslash l.
Highlight output

Scroll through the output.

Observe the list of available databases.
Press q to exit Press q to exit.
Cursor on the termainal. Let us create a new database named sports d b.
Type: CREATE DATABASE sportsdb; Type CREATE DATABASE sports d b semicolon and press Enter to execute the command.
Highlight CREATE DATABASE message. The database is created successfully.
Type: \l and press Enter. Type backslash l and press Enter to verify that sports d b is created.
Highlight sportsdb The new database appears in the list.
Type : q Type q to exit.
Type \c sportsdb Now, type backslash c space sports d b and press Enter to connect to the sports d b database.
Highlight success message Here we can see the output as,

You are now connected to database sports d b as user postgres.

Type \q and press Enter. Type backslash q to exit from the p s q l prompt.
Type: exit and press Enter. Type exit to exit from postgres user.
With this we come to the end of this tutorial.
Slide 6


Summary

In this tutorial we learnt to,

  • Log in to the Linux terminal
  • Switch to postgres user
  • Access psql prompt
  • Create a database using SQL


Let us summarise.
Slide 7

Assignment

As an Assignment,* Create and verify a database named accountsdb.

As an Assignment, please do the following.
Slide 8

Thank you

This Spoken Tutorial is brought to you by Edupyramids Educational Services Private Limited, SINE, IIT Bombay.

Thank you.

Contributors and Content Editors

Madhurig