0% found this document useful (0 votes)
40 views19 pages

Introduction To Structured Query Language (SQL) - 1

SQL is a programming language used to store, manipulate, and retrieve data from relational databases. Some key SQL commands include SELECT to query data from tables, INSERT to add new records, UPDATE to modify existing records, DELETE to remove records, and CREATE to make new database objects like tables and views. SQL can also be used for data administration tasks like creating tables, views, indexes, and databases as well as managing user accounts and permissions.

Uploaded by

akawunggabriel23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
40 views19 pages

Introduction To Structured Query Language (SQL) - 1

SQL is a programming language used to store, manipulate, and retrieve data from relational databases. Some key SQL commands include SELECT to query data from tables, INSERT to add new records, UPDATE to modify existing records, DELETE to remove records, and CREATE to make new database objects like tables and views. SQL can also be used for data administration tasks like creating tables, views, indexes, and databases as well as managing user accounts and permissions.

Uploaded by

akawunggabriel23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 19

Introduction to structured

query language(SQL)
• Structured query language is a programming language used for
storing and processing information in a relational database.
Basic commands and functions of SQL
Some basic sql commands and functions include include;
Select command
This command is used to query data from a
table. It retrieves zero or more rows from
one or more database tables or database
views
INSERT command
This is a command used to add new records
or rows to a table
UPDATE command
This command is used to modify existing
records in a table. Either all rows can be
updated or a subset may be chosen using a
condition. The update command has the
following form: UPDATE table_name
SET column_name=value[,
DELETE command
This command is used to delete existing
records from a table and its also a data
manipulation language. There are three
types of delete in sql, those are:
DROP, DELETE, TRUNCATE
CREATE command
Creates a new database table, view, or other
database objects
JOIN command
This command retrieves data from multiple
tables based on a specific relationship
AGGREGATE function
Thes functions operate on a group of rows
and return a single value. Examples include
SUM, AVG, COUNT, MIN and MAX
STRING functions
These functions manipulate and perform
operations on string values. Examples include
CONCAT, SUBSTRING, LENGTH, UPPER and
LOWER
MATHEMATICAL
FUNCTIONS
These functions performs mathematical
operations on numerical values. Examples
are POWER, ROUND, CEILING
DATE AND TIME
functions
These functions handle date and time values
for example DATE, TIME, NOW, HOUR etc.
Conversion functions
These functions allow you to convert data
types from one form to another. Examples
are CAST, CONVERT, TO_DATE
SQL for data administration
SQL can be used in data administration in the following ways ;
Creating tables:
SQL is commonly used in creating tables in
the database.
- In the diagram, the ‘CREATE TABLE
employees’ is the command to create a
new table called employees.
- ‘employee_id’, ‘first_name’, ’last_name’,
‘department_id’, ‘hire_date’, are the
columns of the table, each with their
respective data types
- INT, VARCHAR, and DECIMAL are
examples of data types. INT represents an
integer, VARCHAR represents a variable-
length character string and DECIMAL
represents a decimal number
- PRIMARY KEY is used to define a column
as a primary key of the table which
uniquely identifies each row
Creating views
A view is a virtual table that is based on the
result of an sql query. The diagram creates a
view that combines employee information
with department names.
- ’CREATE VIEW’ is the command to create
a new view
- ‘SELECT’ is used to create the colums and
data to be included in the view
- ‘FROM’ is used to specify the tables used
in the query
- ‘JOIN’ is used to combine the data from
multiple tables based on a common
column
Creating indexes
Indexes are crucial for improving the
performances of database queries by
facilitating faster data retrieval. The basic
syntax to create an index on a single column
is as shown in the daigram
Database creation
SQL is used to create a new database
specifying the parameters such as database
name, character, set, and collation. The
‘CREATE DATABASE’ statement is used for this
purpose as seen on the diagram
User and permission
management
SQL is used in data management to manage
user accounts and permission, determining
who has access to specific databases, tablets,
or certain operations

You might also like