Dbms Worksheet: Name: - Praduman Kumar Section: - 20ITB5 UID: - 20BCS9446
Dbms Worksheet: Name: - Praduman Kumar Section: - 20ITB5 UID: - 20BCS9446
For c & d) Add column gender in the table with a single character value.
ALTER TABLE table_name
ADD column_name datatype;
For e) UPDATE Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Code:
UPDATE order1
SET gender = M, email_id = [email protected]
WHERE condition;
Ques No 2. Create table student for the given set of attributes and
implement given operations using SQL commands:
2. Query:
Select *, TIMESTAMPDIFF(month, Hiredate, current_date()) as
DiffMonth from employees
where TIMESTAMPDIFF(month, Hiredate, current_date()) between
1 and 5 order by Hiredate desc;
3. Note: Here in query 1 and 5 are indicates 1 to n months which show
the Employees who have hired last 1 to 5 months. In this query,
DiffMonth is an extra column for our understanding which shows the
Nth months.
4. Output:
Query:
Query:
select *, TIMESTAMPDIFF(year, Hiredate, current_date()) as
DiffYear from employees
where TIMESTAMPDIFF(year, Hiredate, current_date())
between 1 and 4 order by Hiredate desc;
Note: Here in query 1 and 4 are indicates 1 to n years which shows
the Employees who have hired last 1 to 4 years. In this query,
DiffYear is a extra column for our understanding which show the Nth
years.
Output:
Query:
select *from employees where Fname like 'A%';
Code:-
Screenshots:-