SQL - Query
SQL - Query
Step-1:
FirstName VARCHAR(50),
LastName VARCHAR(50),
Department VARCHAR(50)
);
Step-2;
DELIMITER //
BEGIN
FROM Employees
END //
DELIMITER ;
Step-3
CALL GetEmployeeDetails(1);
Another pbm:
Step-2:
DELIMITER //
CREATE PROCEDURE ManageEmployee(
IN Action VARCHAR(10),
IN EmployeeID INT,
IN FirstName VARCHAR(50),
IN LastName VARCHAR(50),
IN Department VARCHAR(50)
BEGIN
UPDATE Employees
END IF;
END //
DELIMITER ;
Step-3
Date:
.MySQL comes with the following data types for storing a date or a date/time value in the database:
AUTO INCREMENT
● Auto-increment allows a unique number to be generated automatically when a new record is
inserted into a table.
● Often this is the primary key field that we would like to be created automatically every time a new
record is inserted.
CREATE TABLE Persons (
Personid int NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
PRIMARY KEY (Personid)
);
CREATE INDEX
CREATE INDEX index_name
25
Constraints
● used to specify rules for data in a table
● used to limit the type of data that can go into a table
5.In SQL, a view is a virtual table that represents the result set of a SELECT query.
Unlike physical tables, which store data, views do not store data themselves; instead,
they are dynamically generated based on the underlying tables' data and the query used
to create the view.
Example:
CREATE TABLE Employees (
EmployeeID INT AUTO_INCREMENT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Department VARCHAR(50),
HireDate DATE,
Salary DECIMAL(10, 2)
);