[ 1 ] Let's Begin Practice Session.👉 ..👉...👉
_ 👉. List down Existing databases.
_ 👉. Check Prexisting Databases.
SELECT datname FROM pg_database;
_ 👉. Creating a new Database.
CREATE DATABASE database_name;
_ 👉. Change a Database.
_ 👉. Deleting a Database.
Here as,
\c Database_name;
DROP DATABASE database_name;
_ [ 2 ] CRUD Operations
👊 Most Basic Operations in SQL Query.
_ 👉. CREATE
_ 👉. READ
_ 👉. UPDATE
_ 👉. DELETE
_ # [ 3 ] Table : A Table is a collection of related data help in a table format with in a database.
_ 👊. Creating a New Table
💭 CREATE _ : Creates a new table, database, index, etc.
CREATE TABLE Person(
Index INTEGER PRIMARY KEY
,"User_Id" VARCHAR(30)
,"First_Name" VARCHAR(20)
,"Last_Name" VARCHAR(20)
,Sex VARCHAR(10)
,Email VARCHAR(50)
,Phone VARCHAR(50)
,"Date_of_birth" DATE
,"Job_Title" VARCHAR(100)
);
_ 👊. Inserting Data into existing Table.
💭 INSERT _ : Adds new records into a table.
INSERT INTO Person(Index,"User_Id","First_Name","Last_Name",Sex,Email,Phone,"Date_of_birth","Job_Title") VALUES (1,'e09c4f4cbfEFaFd','Dawn','Trevino','Male','clintongood@example.org','360-423-5286','1972-01-17','Teacher, primary school');
INSERT INTO Person(Index,"User_Id","First_Name","Last_Name",Sex,Email,Phone,"Date_of_birth","Job_Title") VALUES (2,'D781D28b845Ab9D','Dale','Mcknight','Male','clairebradshaw@example.org','9062423229','1931-01-31','Development worker, community');
INSERT INTO Person(Index,"User_Id","First_Name","Last_Name",Sex,Email,Phone,"Date_of_birth","Job_Title") VALUES (3,'eda7EcaF87b2D80','Herbert','Bean','Female','johnnybooker@example.org','001-149-154-0679x1617','2018-02-10','Ceramics designer');
INSERT INTO Person(Index,"User_Id","First_Name","Last_Name",Sex,Email,Phone,"Date_of_birth","Job_Title") VALUES (4,'E75ACea5D7AeC3e','Karen','Everett','Female','wkhan@example.org','870.294.7563x20939','1938-06-14','Civil engineer, consulting');
INSERT INTO Person(Index,"User_Id","First_Name","Last_Name",Sex,Email,Phone,"Date_of_birth","Job_Title") VALUES (10,'Ae5E6FBeCdcb982','Jean','Ferrell','Female','alejandraadkins@example.com','(660)872-0844x8093','1947-01-13','Careers information officer');
Here It will Show Entire Table Data.
SELECT * FROM Person;
Let's Continue .😊
Comments