Q1) Alter your emp table to add a new column password with CHAR(7) datatype. The result should be like below: [image below src__q.png] Q2). Please write a DML statement to update password data in your emp table password column. The password data formular should be the first three characters of the ename concates deptno concates the first two digits of empno. The result should be like below: [image below src__q2.png] [Before DML Statement]
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
Q1) Alter your emp table to add a new column password with CHAR(7) datatype. The result should be like below:
[image below src__q.png]
Q2). Please write a DML statement to update password data in your emp table password column. The password data formular should be the first three characters of the ename concates deptno concates the first two digits of empno. The result should be like below:
[image below src__q2.png]
[Before DML Statement]
Martial needed to answer the questions above:
- https://drive.google.com/file/d/14OwWDIybjAIeuHCO7McupV08gJs9nB-8/view?usp=sharing
- https://drive.google.com/file/d/1npRH8JoJ6GYBzPU3iNjLXluvCyhr2tMu/view?usp=sharing
![[Check your Table Structure Before altering emp]
SQL> DESC emp
Name
Null?
Туре
NOT NULL NUMBER ( 4)
VARCHAR2 (10)
VARCHAR2 (9)
NUMBER ( 4)
EMPNO
ENAME
JÓB
MGR
HIREDATE
DATE
NUMBER ( 7,2)
NUMBER ( 7,2)
NOT NULL NUMBER (2)
SAL
COMM
DEPTNO
SQL> ALTER TABLE emp ADD(.....);
[Check your Table Structure After altering emp]
SQL> DESC emp
Name
Null?
Туре
EMPNO
NOT NULL NUMBER (4)
ΕΝΜΕ
VARCHAR2 (10)
JOB
VARCHAR2 (9)
MGR
NUMBER (4)
HIREDATE
DATE
NUMBER ( 7,2)
NUMBER (7,2)
NOT NULL NUMBER (2)
SAL
COMM
DEPTNO
PASSWORD
CHAR (7)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdc587c31-a247-493d-b2ae-563348ff8a62%2F1536cfaf-3706-4e45-bc58-44255459a631%2Fgrm8pbl_processed.png&w=3840&q=75)
![SQL> SELECT * FROM emp;
EMPNO ENAME
JOB
MGR HIREDATE
SAL
COMM
DEPTNO PASSWOR
7839 KING
PRESIDENT
17-NOV-81
5000
10
7698 BLAKE
MANAGER
7839 01-MAY-81
2850
30
7782 CLARK
MANAGER
7839 09-JUN-81
2450
10
7566 JONES
MANAGER
7839 02-APR-81
2975
20
7654 MARTIN
SALESMAN
7698 28-SEP-81
1250
1400
30
7499 ALLEN
SALESMAN
7698 20-FEB-81
1600
300
30
7844 TURNER
SALESMAN
7698 08-SEP-81
1500
30
7900 JAMES
CLERK
7698 03-DEC-81
950
30
7521 WARD
SALESMAN
7698 22-FEB-81
1250
500
30
7902 FORD
ANALYST
7566 03-DEC-81
3000
20
7369 SMITH
CLERK
7902 17-DEC-80
800
20
7788 SCOTT
ANALYST
7566 09-DEC-82
3000
20
7876 ADAMS
CLERK
7788 12-JAN-83
1100
20
7934 MILLER
CLERK
7782 23-JAN-82
1300
10
SQL> UPDATE emp
SET password = ..;
[After DML Statement]
SQL> SELECT * FROM emp;
ΕMPNO ΕΝΑΜΕ
JOB
MGR HIREDATE
SAL
COMM
DEPTNO PASSWOR
7839 KING
PRESIDENT
17-NOV-81
5000
10 KIN1078
7698 BLAKE
MANAGER
7839 01-MAY-81
2850
30 BLA3076
7782 CLARK
MANAGER
7839 09-JUN-81
2450
10 CLA1077
7566 JONES
MANAGER
7839 02-APR-81
2975
20 JON2075
7654 MARTIN
SALESMAN
7698 28-SEP-81
1250
1400
30 MAR3076
7499 ALLEN
SALESMAN
7698 20-FEB-81
1600
300
30 ALL3074
7844 TURNER
SALESMAN
7698 08-SEP-81
1500
30 TUR3078
7900 JAMES
CLERK
7698 03-DEC-81
950
30 JAM3079
7521 WARD
SALESMAN
7698 22-FEB-81
1250
500
30 WAR3075
7902 FORD
ANALYST
7566 03-DEC-81
3000
20 FOR2079
7369 SMITH
CLERK
7902 17-DEC-80
800
20 SMI2073
7788 SCOTT
ANALYST
7566 09-DEC-82
3000
20 SC02077
7876 ADAMS
CLERK
7788 12-JAN-83
1100
20 ADA2078
7934 MILLER
CLERK
7782 23-JAN-82
1300
10 MIL1079](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdc587c31-a247-493d-b2ae-563348ff8a62%2F1536cfaf-3706-4e45-bc58-44255459a631%2Fj4cmcy_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









