postgreSQL

0.0(0)
Studied by 1 person
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/8

encourage image

There's no tags or description

Looks like no tags are added yet.

9 Terms

1
New cards

Create Table

Create table with however many empty feilds you want

CREATE TABLE cars (
brand VARCHAR(255)
model VARCHAR(255),
 year INT

);

2
New cards

Insert Into

inserts a row of data into table created
INSERT INTO cars (brand, model, year)
VALUES ('Ford', 'Mustang', 1964);

3
New cards

Fetch Data

retrive data by specifying column name

SELECT brand, year FROM cars

4
New cards

ADD COLUMN

ALTER TABLE cars
ADD color VARCHAR(255);
Use alter table which is used to add, delete, or modify existing columns in a table

5
New cards

Update

used to modify the values in existing records in the table
UPDATE cars
SET color = 'red'
WHERE brand = 'Volvo';

make sure use where otherwise all records will be updated

6
New cards

ALTER COLUMN

change data type of size of column using alter table
ALTER TABLE cars
ALTER COLUMN year TYPE VARCHAR(4);
changes year from into to varchar

7
New cards

drop column

removes column from table, use alter table statement
ALTER TABLE cars
DROP COLUMN color;
gets rid of color column

8
New cards

DELETE

Delete is used to delete existing records in a table
delete all records where brand is volvo
DELETE FROM cars
WHERE brand = 'Volvo';

9
New cards

drop table

used to drop existing table from database
DROP TABLE cars;
gets rid of cars table