Structured Query Language (SQL) is used for accessing databases. It is used to create a table, manage data and manipulate data.
Advantages of using SQL:
1) SQL is portable
2) High speed
3) Easy to learn and understand:
4) SQL is used for relational databases
Types of SQL Statements
The SQL statements are categorized into different categories based upon the purpose. They are;
i) Data Definition Language (DDL) statement
ii) Data Manipulation Language (DML) statement
Data Types:- Each value manipulated by SQL Database has a data type.
In SQL there are three main data types: Character, Number, and Date types.
Character data types stores character (alphanumeric) data. Character columns can store all alphabet or alphanumeric values, but number columns can store only numeric values.
Character data types are;
i) CHAR
ii) VARCHAR
Note:- if we store Name is as “AMIT” then size in case of var will be 10 and in case of varchar
size will be 4
Numeric data type: Numeric data types are mainly used to store number with or without fraction part. The numeric data types are:
1. NUMBER/INT/NUMERIC:- used to store integer value only
2. DECIMAL/FLOAT:- used to store decimal value. For example salary float(6,2). Here 6 is the total digits including 2 decimal digits like (4500.75) so we have total 6 digits including 2 decimal values
3. DATE:-Date is used to store valid date values. The date formats are: YYYY-MM-DD or YYYY/MM/DD Date should be entered in quotes. For example “2004-11-12”
Cartesian product:- Cartesian product is a binary operation and is denoted by (x). It is also known as cross join. In this rows gets multiplied and columns gets added
Cartesian product of table Product and Customer will be
Product x Customer
Degree will be 3+4=7
Cardinality will be 4*5=20
Team NB Learner