SQL for Beginners

PostgreSQL Example – How to Cartesian Product Of Tables

Cartesian Product Of Tables Create Table Of Adventurers – Create table called adventurers CREATE TABLE adventurers ( – string variable name varchar(255), – integer variable age int, – string variable race varchar(255) ) Create Table Of Adventurer’s Equipment – Create table called equipment CREATE TABLE equipment ( – string variable name varchar(255), – string variable …

PostgreSQL Example – How to All Unique Values In Two Tables

All Unique Values In Two Tables Create Table Of Elves – Create table called elves CREATE TABLE elves ( – string variable name varchar(255), – integer variable age int, – string variable race varchar(255), – string variable weapon varchar(255) ) Create Table Of Dwarves – Create table called dwarves CREATE TABLE dwarves ( – string …

PostgreSQL Example – How to Update Rows Based On Another Table

Update Rows Based On Another Table Create Table Of Elves – Create table called elves CREATE TABLE elves ( – string variable name varchar(255), – integer variable age int, – string variable race varchar(255), – string variable alive varchar(255) ) Create Table Of Deaths – Create table called deaths CREATE TABLE deaths ( – string …

PostgreSQL Example – How to Insert Rows

Insert Rows Create Table – Create table called adventurers CREATE TABLE adventurers ( – string variable name varchar(255), – integer variable age int, – string variable race varchar(255), – string variable weapon varchar(255) ) Insert Row – Insert row into the table adventurers INSERT INTO adventurers (name, age, race, weapon) VALUES (‘Fjoak Doom-Wife’, 28, ‘Human’, …

PostgreSQL Example – How to Delete Rows

Delete Rows Create Table – Create table called adventurers CREATE TABLE adventurers ( – string variable name varchar(255), – integer variable age int, – string variable race varchar(255), – string variable weapon varchar(255) ) Insert Rows – Insert into the table adventurers INSERT INTO adventurers (name, age, race, weapon) VALUES (‘Fjoak Doom-Wife’, 28, ‘Human’, ‘Axe’), …

PostgreSQL Example – How to Delete Primary Key

Delete Primary Key Create Table – Create table called adventurers CREATE TABLE adventurers ( – integer variable adventurer_id INT, – string variable name varchar(255), – integer variable age int, – string variable race varchar(255), – string variable weapon varchar(255), PRIMARY KEY (adventurer_id) ) Insert Rows – Insert into the table adventurers INSERT INTO adventurers (adventurer_id, …

PostgreSQL Example – How to Delete Duplicates

Delete Duplicates Create Table Of Elves – Create table called elves CREATE TABLE elves ( – string variable name varchar(255), – integer variable age int, – string variable race varchar(255), – string variable alive varchar(255) ) Insert Rows Into Elf Table INSERT INTO elves (name, age, race, alive) VALUES (‘Dallar Woodfoot’, 25, ‘Elf’, ‘Yes’), (‘Cordin …

PostgreSQL Example – How to Delete All Rows

Delete All Rows Create Table – Create table called adventurers CREATE TABLE adventurers ( – string variable name varchar(255), – integer variable age int, – string variable race varchar(255), – string variable weapon varchar(255) ) Insert Rows – Insert into the table adventurers INSERT INTO adventurers (name, age, race, weapon) VALUES (‘Fjoak Doom-Wife’, 28, ‘Human’, …

PostgreSQL Example – How to Create Primary Key

Create Primary Key Create Table – Create table called adventurers CREATE TABLE adventurers ( – integer variable adventurer_id INT, – string variable name varchar(255), – integer variable age int, – string variable race varchar(255), – string variable weapon varchar(255), PRIMARY KEY (adventurer_id) ) Insert Rows – Insert into the table adventurers INSERT INTO adventurers (adventurer_id, …

PostgreSQL Example – How to Create Column Of Values

Create Column Of Values Create Table – Create table called adventurers CREATE TABLE adventurers ( – string variable name varchar(255), – integer variable age int, – string variable race varchar(255), – string variable weapon varchar(255) ) Insert Rows – Insert into the table adventurers INSERT INTO adventurers (name, age, race, weapon) VALUES (‘Fjoak Doom-Wife’, 28, …