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, name, age, race, weapon)
VALUES (1, 'Fjoak Doom-Wife', 28, 'Human', 'Axe'),
(2, 'Alooneric Cortte', 29, 'Human', 'Bow'),
(3, 'Piperel Ramsay', 35, 'Elf', 'Bow'),
(4, 'Casimir Yardley', 14, 'Elf', 'Bow')
View Table
-- Retrieve all rows
SELECT * FROM adventurers
adventurer_id | name | age | race | weapon |
1 | Fjoak Doom-Wife | 28 | Human | Axe |
2 | Alooneric Cortte | 29 | Human | Bow |
3 | Piperel Ramsay | 35 | Elf | Bow |
4 | Casimir Yardley | 14 | Elf | Bow |
Delete Primary Key
-- Delete primary key of the adventurers' table
ALTER TABLE adventurers DROP CONSTRAINT adventurers_pkey
View Table
-- Retrieve all rows
SELECT * FROM adventurers
adventurer_id | name | age | race | weapon |
1 | Fjoak Doom-Wife | 28 | Human | Axe |
2 | Alooneric Cortte | 29 | Human | Bow |
3 | Piperel Ramsay | 35 | Elf | Bow |
4 | Casimir Yardley | 14 | Elf | Bow |