Introduction to SQL 157a (5) Flashcards
What is SQL?
What does it stand for?
○ SQL stands for Structured Query Language. It is used for storing and managing data in
relational database management system (RDMS).
○ It is a standard language for Relational Database System. It enables a user to create, read, update and delete relational databases and tables.
○ All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server use SQL as their
standard database language.
○ SQL allows users to query the database in a number of ways, using English-like statements
Why is SQL used?
SQL is widely popular because it offers the following advantages −
1. Allows users to access data in the relational database management systems.
2. Allows users to describe the data.
3. Allows users to define the data in a database and manipulate that data.
4. Allows to embed within other languages using SQL modules, libraries & pre-compilers.
5. Allows users to create and drop databases and tables.
6. Allows users to create view, stored procedure, functions in a database.
7. Allows users to set permissions on tables, procedures and views.
How does SQL work?
How SQL Works?
○ When an SQL command is executing for any RDBMS, then the system figure out the best way to carry out the request and the SQL engine determines that how to interpret the task.
○ In the process, various components are included. These components can be optimization Engine, Query engine, Query dispatcher, classic, etc.
○ All the non-SQL queries are handled by the classic query engine, but SQL query engine won’t handle logical files.
Important SQL characteristics
● SQL is easy to learn.
● SQL is used to access data from relational database management systems.
● SQL can execute queries against the database.
● SQL is used to describe the data.
● SQL is used to define the data in the database and manipulate it when needed.
● SQL is used to create and drop the database and table.
● SQL is used to create a view, stored procedure, function in a database.
● SQL allows users to set permissions on tables, procedures, and views
SQL advantages
- High Speed
- No coding needed
- Well defined standards
- portability
- interactive language
- Multiple data view
SQL Data types
- SQL datatype is used to define the values that a column can contain
- Every column is required to have a name and data type in the database table
- Binary DataType
- Numeric Datatype
- Extract Numberic Datatype
- String Datatype
- Date Datatype
What are Binary Datatypes?
There are Three types of
binary Datatypes which are
given below:
- Binary: It has a maximum length of 8000 bytes. It contains fixed length binary data
- Varbinary: It has a maximum length of 8000 bytes. It contains variable length binary data
- image: it has a maximum lenght of 2,147,483,647 bytes. It contains variable length binary data.
Approximate Numeric Datatype
The subtypes are below:
- float: It is used to specify a floating point value
- real: it specifies a single precision floating point number
Exact Numeric Datatype
Subtypes are given below:
- int: it is used to specify an integer value
- smallint: it is used to specify fmall integer value.
- bit: it has the number of bits to store
- decimal: it specifies a numeric value that can have a decimal number
- numeric: it is used to specify a numeric value
Character String Datatype
subtypes given below
- It has a maximum length of 8000 characters. It contains Fixed length non unicode characters.
- varchar: it has a maximum length of 8000 characters. It contains variable-length non unicode characters
- text: it has a maximum length of 2,147,483,647 characters. it contains variable length non unicode characters.
Date and time datatypes
subtypes given below
- date: it is used to store the year, month , and days value.
- time: it is used to store the hour, minute , and second values
- timestamp: it stores the year, month, day, hour, minute, and the second value.
SQL Commands
○ SQL commands are instructions. It is used to communicate with the database. It is also
used to perform specific tasks, functions, and queries of data.
○ SQL can perform various tasks like create a table, add data to tables, drop the table,
modify the table, set permission for users.
Types of SQL Commands
DDL, DML, DCL, TCL, DQL
DDL Commands
- Create
- Drop
- Alter
- Truncate
DML Commands
- Insert
- update
- delete