0% found this document useful (0 votes)
21 views13 pages

SQL Basics: Key Concepts Explained

The document covers SQL basics, including definitions of SQL, MySQL, and types of SQL commands such as DDL, DML, DCL, and TCL. It explains key concepts like primary keys, foreign keys, data types, constraints, data integrity, and differences between commands like DELETE and TRUNCATE, as well as UNION and UNION ALL. Additionally, it highlights the distinctions between primary keys and unique keys.

Uploaded by

arutselvan.tems
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)
21 views13 pages

SQL Basics: Key Concepts Explained

The document covers SQL basics, including definitions of SQL, MySQL, and types of SQL commands such as DDL, DML, DCL, and TCL. It explains key concepts like primary keys, foreign keys, data types, constraints, data integrity, and differences between commands like DELETE and TRUNCATE, as well as UNION and UNION ALL. Additionally, it highlights the distinctions between primary keys and unique keys.

Uploaded by

arutselvan.tems
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

DAY-1

SQL Basics Q’s

@tunishavyas
What is SQL, and what are its different
components?

SQL (Structured Query Language) used for managing


and manipulating data in relational database
management systems (RDBMS).
Its different components include Data Definition
Language (DDL), Data Manipulation Language (DML),
Data Control Language (DCL), and Transaction
Control Language (TCL).

@tunishavyas
What is the difference between SQL and
MySQL?

SQL is a language used to manage and manipulate


data in a database, whereas MySQL is an open-
source relational database management system that
uses SQL as its language.

@tunishavyas
What are the different types of SQL
commands?

The different types of SQL commands include DDL


(Data Definition Language), DML (Data Manipulation
Language), DCL (Data Control Language), and TCL
(Transaction Control Language).

@tunishavyas
What is a primary key?

A primary key is a column or group of columns that


uniquely identifies each row in a table. It must contain
unique values and cannot have NULL values.

CREATE TABLE Persons (


ID int ,
PRIMARY KEY (ID)
);

@tunishavyas
What is a foreign key?

A foreign key is a column or a group of columns in a


table that references the primary key of another table.
It establishes a link between the data in the two
tables.

CREATE TABLE Orders (


PersonID int,
FOREIGN KEY (PersonID) REFERENCES
Persons(PersonID)
);

@tunishavyas
What is the difference between CHAR
and VARCHAR data types?

The main difference between CHAR and VARCHAR


data types is that CHAR is a fixed-length character
data type, whereas VARCHAR is a variable-length
character data type.

@tunishavyas
What is the difference between DELETE
and TRUNCATE commands?

DELETE is a DML command used to remove specific


rows from a table, while TRUNCATE is a DDL
command used to remove all rows from a table.

@tunishavyas
What is a constraint in SQL?

A constraint in SQL is a rule that is enforced on the


data in a table. It can be used to enforce data integrity
and to ensure that data meets certain criteria.

@tunishavyas
The following constraints are commonly used in SQL:
NOT NULL - Ensures that a column cannot have
a NULL value
UNIQUE - Ensures that all values in a column are
different
PRIMARY KEY - A combination of a NOT NULL
and UNIQUE. Uniquely identifies each row in a
table
FOREIGN KEY - Prevents actions that would
destroy links between tables
CHECK - Ensures that the values in a column
satisfies a specific condition
DEFAULT - Sets a default value for a column if
no value is specified
CREATE INDEX - Used to create and retrieve
data from the database very quickly

@tunishavyas
Explain the concept of data integrity in
SQL.

Data integrity in SQL refers to the accuracy and


consistency of data stored in a database. It ensures
that data remains accurate, reliable, and accessible
over time.

@tunishavyas
What is the difference between UNION
and UNION ALL?

UNION is used to combine the result sets of two or


more SELECT statements and removes duplicate
rows, whereas UNION ALL also combines the result
sets but retains all rows, including duplicates.

@tunishavyas
What is the difference between a primary
key and a unique key?

A primary key is a column or group of columns that


uniquely identifies each row in a table and does not
allow NULL values, while a unique key ensures that
all values in a column are different. Unlike the primary
key, it allows NULL values.

@tunishavyas

You might also like