Skip to content

Latest commit

 

History

History
85 lines (67 loc) · 2.41 KB

File metadata and controls

85 lines (67 loc) · 2.41 KB

<<<----- Basic Command (Create, Alter, Drop, Add, Update, Delete)


1.1 - Example 1

Movie Table

devrimmehmet


Step 1 : Create Database

create database devrimmehmet;
Don't forget to change the database here (pay attention to the red rectangle)

dont-forget-change-db

Press here to run (pay attention to the green rectangle)

dont-forget-change-db

Go by constantly checking what you have done with a select query.(pay attention to the blue rectangle)

dont-forget-change-db

Step 2 : Create Tables

create table users(user_id int, first_name varchar(100), last_name varchar(100), email varchar(255), encrypted_password varchar(1000));
create table movies (movie_id int, title varchar(100), description varchar(100), price varchar(255));
create table purchases(user_id int, movie_id int, purchase_date varchar(255), purchase_price varchar(100));

Step 3 : Add rows ( Insert )

insert into movies (movie_id,title,description,price) values (1,'The Last Of Castle', 'Movie or Documentary', 4.99)
insert into movies (title,price) values ('Into The Wild', 6.99)
insert into movies (title,price) values ('Eternal sunshine of the spotless mind', 7.99)
insert into movies (title,price) values ('Soul', 8.88)
insert into movies (title,price) values ('Test', 9.99)

Step 4 : Select

select * from movies
select title, price from movies

Step 5 : Order By [column] --> Ascending sort

select title, price from movies order by price; 

Step 6 : Order By [column] --> Descending sort

select title, price from movies order by price desc;

Step 7 : Update

update movies set price=0.99 where title='Soul' 
select * from movies

Step 8 : Delete

delete from movies where title='Test'
select * from movies

----->>> Relational Databases