요즘 SQL 수업을 듣고 있는 중인데, 원체 프로그래밍과 거리가 먼 전공에, 업무를 경험하였더니 수업을 따라가는 것도 헉헉거리는데, 그나마 인간이 게으르기까지 해서 점차 수업이 버거워지고 있다. 역시 재능 중의 재능은 성실함인가... 쩝.
그래서 복습 겸 앞 부분을 보고 있는 중인데, 수업 시간에 멍~ 했던 부분이 조금씩 이해되기 시작한다! 두둥~ 역시 숙제도 안하고 복습도 안하면서 프로그래밍 천재!가 되기엔 나는 너무 범재인걸 ㅠㅠ
뭐, 일단 공부한 내용들 조금씩 올려보면서 SQL에 당분간 매진해봐야지.
-- Basic #1. Create Table
Create Table {DataSource}
(
ColumnName 1 integer primary key,
ColumnName 2 Varchar (**) not null,
ColumnName 3 Char (**),
ColumnName 4 date (mm-dd-yyyy) not null
)
;
-- Basic #2. Alter Table
Alter Table {DataSource}
Add column {ColumnName} {condition}
;
-- Basic #3. Drop Table
Drop Table {DataSource}
;
-- Basic #4. Insert syntax
Insert into {DataSource}
(ColumnName 1, ColumnName 2, ... , ColumnName n)
values
(value 1, value 2, ... , value n)
;
-- Basic #5. Insert from another table
Insert into {DataSource1}
select * from {DataSource2}
;
-- Basic #6. Update syntax
Update {DataSource}
set {condition1}
where {condition2}
;
-- Basic #7. Delete syntax
Delete from {DataSource}
where {condition}
;
-- Basic #8. Select ALL rows and columns from a single table
select * from {DataSource}
;
-- Basic #9. Select SPECIFIC colums from all rows in a single table
select {selectlist}
from {DataSource}
;
-- Basic #10. Select specific columns which meet a specific condition
select {selectlist}
from {DataSource}
where {condition}
;
-- Basic #11. Select command with more than one table
select [AS].{selectlist}
from {DataSource1} [AS1], {DataSource2} [AS2]
where {condition}
;
-- Basic #12. Insert a set of row into the table
Copy {DataSource} from '{DataRoot}' (delimiter ',')
;
-- Basic #13. Logical/Comparison/Arthmetic operation in Where Clause
AND OR NOT < <= = >= > <> + - * /
-- Basic #14. Union of two selects
select * from {DataSource1}
Union
select * from {DataSource2}
;
-- Basic #14. In / Not In Clause
select {selectlist}
from {DataSource1}
where ColumnName
IN
(select ColumnName from {DataSource2})
;
-- Basic #15. Exists / Not Exists Clause
select {selectlist}
from {DataSource1}
where ColumnName
Exists
(select ColumnName from {DataSource2})
;
*Sublime Text 만만세!!!