SQL 1. Create a new table in the database called DEPT_TEST. It will have four co
ID: 3700595 • Letter: S
Question
SQL
1. Create a new table in the database called DEPT_TEST.
It will have four columns: id, dept_name, dept_city, and dept_budget.
The ID is a fixed length number with 7 digits. It serves as the primary key.
Dept_name is a text field that will list the department name (e.g. accounting, finance, and so on).
Dept_city is the city where the department is located.
Dept_budget will include the budget for the department up to 2 decimal places (a typical department budget in this company would be around $10,000.
2. Populate the DEPT_TEST table with the following value:
ID
DEPT_NAME
DEPT_CITY
DEPT_BUDGET
1178999
accounting
chicago
5000
3. Populate the DEPT_TEST table with the following value:
ID
DEPT_NAME
DEPT_CITY
DEPT_BUDGET
1178900
finance
abilene
7000
4. Change the dept_name of ID 1178999 from accounting to HR.
5. Change the dept_city of dept_id 1178900 to new york.
6. Delete the dept_test table.
ID
DEPT_NAME
DEPT_CITY
DEPT_BUDGET
1178999
accounting
chicago
5000
Explanation / Answer
1.) Create table DEPT_TEST(
id int(7) NOT NULL,
Dept_name varchar(255),
Dept_city varchar(255),
Dept_budget float(6,2),
PRIMARY KEY(id)
);
2.) Insert into DEPT_TEST (ID, DEPT_NAME, DEPT_CITY, DEPT_BUDGET)
Values (1178999, 'accounting', 'chicago',5000);
3.) Insert into DEPT_TEST (ID, DEPT_NAME, DEPT_CITY, DEPT_BUDGET)
Values (1178900, 'finance', 'abilene',7000);
4.) Update DEPT_TEST
set dept_name = 'HR'
where ID = 1178999;
5.) Update DEPT_TEST
set dept_city = 'New York'
where ID = 1178900;
6.) Delete from DEPT_TEST;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.