1/8
Looks like no tags are added yet.
Create Table
Create table with however many empty feilds you want
CREATE TABLE cars (
brand VARCHAR(255)
model VARCHAR(255),
year INT
);
Insert Into
inserts a row of data into table created
INSERT INTO cars (brand, model, year)
VALUES ('Ford', 'Mustang', 1964);
Fetch Data
retrive data by specifying column name
SELECT brand, year FROM cars
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
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
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
drop column
removes column from table, use alter table statement
ALTER TABLE cars
DROP COLUMN color;
gets rid of color column
DELETE
Delete is used to delete existing records in a table
delete all records where brand is volvo
DELETE FROM cars
WHERE brand = 'Volvo';
drop table
used to drop existing table from database
DROP TABLE cars;
gets rid of cars table