Basics of SQL

It’s been a while since I touched databases. I was looking for some of the notes I made on SQL way back, but after about a couple minutes of not being able to find it, I just Googled my way to the basics that is essential to SQL.

Here are the essentials followed by some examples I made myself:

Selecting Data
select column1, column2, column3
from table name
where “condition” (e.g first LIKE, age > 24, etc)

Example:
SELECT First, Last, EmpID
FROM employinfo
WHERE age>30;

Creating Tables
CREATE  table name
(first varchar(15),
last var char (18),
empid number(5),
ssnum number (9) );

Datatypes:
char(size)
date
number (size) or number(size,d) where d is the digits to the right of decimal
varchar(size)

Updating:
UPDATE table name
SET columname = newname
WHEREcolumnar = previous name;

Example:
UPDATE employinfo
SET name = Josh
WHERE name = John

Delete:
DELETE from table name
WHERE column name = ‘value';

Example:
DELETE from employinfo
WHEREname = ‘Josh';

Leave a Reply

*

Next ArticleThe importance of failure