COMMON/INTRODUCTORY SQL COMMANDS
BY JONATHAN RINFRET
JONATHAN.RINFRET@MY.GAVILAN.EDU


(sql is not case sensitive)


***SQL DATABASES***

CREATE DATABASE;
Create database csis24;

SHOW DATABASES;

DROP DATABASE;
Drop database csis24;


***SQL TABLES***

CREATE TABLE table_name (column1name, column1type, column1details, column2name…)  DEFAULT CHARACTER SET CHARSET ENGINE= INNODB;

Show tables;

Describe table_name;

Drop table table_name;

***EXAMPLES***

Create table student_grades (
Id int not null auto_increment primary key
Name text
Grade decimal (or varchar (or char) for a character)
)Default character set utf8 engine=innodb;

Describe table student_grades;

Drop table student_grades;


***SQL INSERTS***

Insert into table_name set 
Column1name = column1value,
Column2name = column2value,;
…


***EXAMPLES***

Insert into student_grades set
Name = jonathan Rinfret,
Grade = “80” (or B as a varchar or char),;


***SQL UPDATES***

UPDATE TABLE_NAME SET
COLUMN1NAME = NEW VALUE…
WHERE (CONDITIONS);

***EXAMPLES***

Update Stdent_grades set
Grade = “90”
Where name = “Alex”;


***SQL QUERIES***

Select * from table_name;
Select column1name, column2name from table_name;
Select column1name, from table_name where Column2name >= value;
Select column2name, from table_name where Column1name like value;

***EXAMPLES***

Select * from Student_Grades;
Select name, grade from student_grades;
Select name from Student_grades where grade >= “80”;
Select grade from Student_grades where name like  “%ALEX%” and grade > “70”;


