Chapter 10 MySQL
Chapter 10 MySQL
LANGUAGE(SQL)
Basic Database concepts
Characteristics of SQL
3. View Definition:
GRANT, REVOKE
Structured Query Language
COMMIT, ROLLBACK
Data types of SQL
Just like any other programming language, the facility of
defining data of various types is available in SQL also.
Following are the most common data types of SQL.
1. INTEGER
2. SMALLINT
3. CHAR
4. VARCHAR / VARCHAR2
5. DATE
6. LONG
7. RAW/LONG RAW
Data types of SQL
1. INTEGER
INT
2. SMALLINT
SMALLINT
Data types of SQL
1. Decimal
Decimal(n,d)
2. CHAR
3. VARCHAR/VARCHAR2
varchar(size) / varchar2(size)
5. LONG
6. RAW/LONG RAW
Constraints:
1. NOT NULL
2. UNIQUE
3. PRIMARY KEY
4. FOREIGN KEY
5. CHECK
6. DEFAULT
SQL Commands
Constraints:
Constraints:
Constraints:
Constraints:
Constraints:
Adding a column
The syntax to add a column is:-
If we give command
Removing a column
Note that we have just added a column and there will be no data
under this attribute. Insert/UPDATE command can be used to
supply values / data to this column and update data once added.
mysql> desc student; will give structure of the table
DROP TABLE Command
Operators in SQL:
Queries:
SELECT Command
SELECT Command
SELECT Command
Name
Rohan
Aneeta
Pawan Kumar
SQL Commands
SQL provides two wild card characters that are used while
comparing the strings with LIKE operator.
ORDER BY Clause
ORDER BY Clause
GROUP BY Clause
GROUP BY Clause
GROUP BY city;
SQL Commands
HAVING Clause
HAVING Clause
1. Mathematical functions
2. String functions
UPDATE Command
UPDATE Command
The CARTESIAN
JOIN or CROSS
JOIN returns the
Cartesian
product of the
sets of records
from two or
more joined
tables. Thus, it
equates to an
inner join.
SQL> SELECT ID, NAME,
AMOUNT, DATE FROM
CUSTOMERS, ORDERS;
SELECTION AND PROJECTION
i. Database Abstraction
Ans: When two or more entries about the same data do not
agree i.e. when one of them stores the updated information
and the other does not, it results in data inconsistency in the
database.
Relational Algebra
v. Candidate Key
vii. Domain