0% found this document useful (0 votes)
0 views

SQL NOTES

SQL (Structured Query Language) is a programming language for managing data in relational databases, utilizing concepts like tables, fields, and keys. Key SQL commands include SELECT, INSERT INTO, UPDATE, DELETE FROM, CREATE TABLE, and ALTER TABLE, each serving specific functions for data manipulation. This document serves as an introductory guide for Grade 9 IT students, emphasizing the importance of practice and providing foundational knowledge for further learning in SQL.

Uploaded by

ricomorales230
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

SQL NOTES

SQL (Structured Query Language) is a programming language for managing data in relational databases, utilizing concepts like tables, fields, and keys. Key SQL commands include SELECT, INSERT INTO, UPDATE, DELETE FROM, CREATE TABLE, and ALTER TABLE, each serving specific functions for data manipulation. This document serves as an introductory guide for Grade 9 IT students, emphasizing the importance of practice and providing foundational knowledge for further learning in SQL.

Uploaded by

ricomorales230
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL Content Notes for Grade 9 IT

What is SQL?
SQL (Structured Query Language) is a programming language used for managing and
manipulating data in relational databases. Think of it as the way you talk to a database to get the
information you need.
Key Concepts:
* Relational Databases: Databases organized into tables with rows (records) and columns
(fields).
* Tables: Collections of related data. Like a spreadsheet, but more structured.
* Fields (Columns): Represent specific attributes of the data (e.g., Name, Age, City).
* Records (Rows): Represent a single instance of the data (e.g., one student's information).
* Primary Key: A unique identifier for each record in a table (e.g., StudentID).
* Foreign Key: A field in one table that refers to the primary key in another table, used to link
tables together.
Basic SQL Commands:
SELECT: Used to retrieve data from a database.
SELECT column1, column2, ... FROM table_name; -- Selects specific columns
SELECT * FROM table_name;-- Selects all columns

Example: SELECT Name, Age FROM Students;


* WHERE: Used to filter data based on a condition.
SELECT column1, column2, ... FROM table_name WHERE condition;

Example: SELECT Name FROM Students WHERE Age > 15;


* INSERT INTO: Used to add new records to a table.
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);

Example: INSERT INTO Students (Name, Age) VALUES ('Jane Doe', 16);
* UPDATE: Used to modify existing records in a table.
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;

Example: UPDATE Students SET Age = 17 WHERE Name = 'Jane Doe';


* DELETE FROM: Used to remove records from a table.
DELETE FROM table_name WHERE condition;

Example: DELETE FROM Students WHERE StudentID = 123;


* CREATE TABLE: Used to create a new table in the database.
CREATE TABLE table_name (
column1 datatype constraints,
column2 datatype constraints,
...
);

Example:
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
Name VARCHAR(255),
Age INT
);

* ALTER TABLE: Used to modify the structure of an existing table (e.g., add or remove
columns).
ALTER TABLE table_name ADD column_name datatype;
ALTER TABLE table_name DROP COLUMN column_name;
* DROP TABLE: Used to delete an entire table from the database.
DROP TABLE table_name;

Data Types:
Common data types you'll encounter:
* INT: Integer numbers.
* VARCHAR(n): Text strings of variable length (up to n characters).
* DATE: Dates (YYYY-MM-DD).
* BOOLEAN: True/False values.
Operators:
* =: Equal to
* >: Greater than
* <: Less than
* >=: Greater than or equal to
* <=: Less than or equal to
* != or <>: Not equal to
* LIKE: Used for pattern matching (e.g., WHERE Name LIKE 'J%'; finds names starting with
'J').
* AND, OR, NOT: Logical operators to combine conditions.
Important Notes:
* SQL commands are generally not case-sensitive (e.g., SELECT is the same as select), but it's
good practice to use uppercase for commands and lowercase for table and column names for
readability.
* Semicolons (;) are used to separate SQL statements.
* Practice is key to learning SQL. Try writing and running simple queries on a sample database.
This provides a good starting point for Grade 9 IT students learning SQL. As they progress, they
can learn more advanced topics like joins, subqueries, indexes, and database design principles.

You might also like