Part 1: Introduction to Oracle & SQL Structure

Oracle Introduction & Basic SQL Concepts
SQL is a language — it is an ANSI standard language.
ANSI stands for American National Standards Institute.
Oracle, MySQL, and DB2 are products — implementations of the SQL language.

1️⃣ What is Database: Collection of Related Table
Table — collection of record
Record — collection of fields
Fields — used to store the particular values

DEPT -> name of Table
---------------------------------
DEPTNO         DNAME -> DNAME is Field
  10            EDP -> EDP is the value of Field
  20           SALES -> info in a row is a Record
  30          ACCOUNT

2️⃣ Data should be organized in rows and columns, not in freeform text like a journal.
There must also be relations between tables — usually established through primary keys (PK) and foreign keys (FK).
PK (Primary Key): a field that uniquely identifies each record in the table
FK (Foreign Key): a field that refers to the PK of another table
This ensures referential integrity — an FK must point to an existing PK in another table.

3️⃣SQL vs PL/SQL
SQL is a declarative language — it’s used to query, insert, update, and delete data.
You just simply describe what you want to do, not how to do it.
SQL is not case-sensitive for commands, but data values are case-sensitive.
SQL statements must end with a semicolon ;.
PL/SQL is a procedural language — it supports logic control like variables, IF conditions, loops, functions, etc.
It is used to organize and control the flow of SQL statements.
In short:
SQL is the core language for manipulating data.
PL/SQL is the language used to orchestrate SQL operations with logic and flow control.

4️⃣ SQL Categories
SQL includes DQL DML DDL TCL DCL.
DQL — DATA retrieval — SELECT query statement
DML — Data manipulation language — INSERT, UPDATE, DELETE, MERGE
DDL — Data definition language — CREATE, ALTER, DROP, RENAME, TRUNCATE, FLASHBACK, PURGE
TCL — Transaction control language — COMMIT, ROLLBACK, SAVEPOINT
DCL — Data control language — GRANT, REVOKE (assign/revoke permissions)

5️⃣SELECT complete syntax:
SELECT column name
FROM table name
WHERE condition
GROUP BY a column
HAVING aggregation condition
ORDER BY a column


评论

留下评论