Question
Mandatory assignment 1 Part 1 What to do? Answer the following tasks by typing the SQL statements that give the given result. For each task,
Mandatory assignment 1 Part 1 What to do? Answer the following tasks by typing the SQL statements that give the given result. For each task, type the sql command and end with the semicolon (;) as follows: select * from the dept; You should not include the actual result, just command.
The tables you need, emp (employees) and dept (departments), create the script file that is enclosed: Script creates tables Required 1.sqlPreview the document The script is deleted from the tables and if they already exist and then create these again and insert "standard data" as the basis for exercises. If you cut the contents of the tables with other values, you can only run this font to reset the tables. Download the script and run it in the workbench, then try to solve the tasks.
Here are the script:
-- MySQL dump 10.13 Distrib 5.6.27, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: oblig1
-- ------------------------------------------------------
-- Server version5.6.27-0ubuntu0.15.04.1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'
*/;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `dept`
--
DROP TABLE IF EXISTS `dept`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dept` (
`deptno` int(11) NOT NULL AUTO_INCREMENT,
`dname` varchar(100) DEFAULT NULL,
`loc` varchar(100) DEFAULT NULL,
PRIMARY KEY (`deptno`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `dept`
--
LOCK TABLES `dept` WRITE;
/*!40000 ALTER TABLE `dept` DISABLE KEYS */;
INSERT INTO `dept` VALUES
(1,'Accounting','New York'),
(2,'Research','Dallas'),
(3,'Sales','Chicago'),
(4,'Operations','Boston');
/*!40000 ALTER TABLE `dept` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `emp`
--
DROP TABLE IF EXISTS `emp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp` (
`empno` int(11) NOT NULL AUTO_INCREMENT,
`ename` varchar(100) DEFAULT NULL,
`job` varchar(100) DEFAULT NULL,
`mgr` int(11) DEFAULT NULL,
`hiredate` datetime DEFAULT NULL,
`sal` float DEFAULT NULL,
`comm` float DEFAULT NULL,
`deptno` int(11) DEFAULT NULL,
PRIMARY KEY (`empno`)
) ENGINE=InnoDB AUTO_INCREMENT=7935 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `emp`
--
LOCK TABLES `emp` WRITE;
/*!40000 ALTER TABLE `emp` DISABLE KEYS */;
INSERT INTO `emp` VALUES
(7369,'Smith','Clerk',7902,'1980-12-17 00:00:00',800,NULL,2),
(7499,'Allen','Salesman',7698,'1981-02-20 00:00:00',1600,300,3),
(7521,'Ward','Salesman',7698,'0000-00-00 00:00:00',1250,500,3),
(7566,'Jones','Manager',7839,'0000-00-00 00:00:00',2975,NULL,2),
(7654,'Martin','Salesman',7698,'0000-00-00 00:00:00',1250,1400,3),
(7698,'Blake','Manager',7839,'0000-00-00 00:00:00',2850,NULL,3),
(7782,'Clark','Manager',7839,'0000-00-00 00:00:00',2450,NULL,1),
(7788,'Scott','Analyst',7566,'0000-00-00 00:00:00',3000,NULL,2),
(7839,'King','President',NULL,'0000-00-00 00:00:00',5000,NULL,1),
(7844,'Turner','Salesman',7698,'0000-00-00 00:00:00',1500,0,3),
(7876,'Adams','Clerk',7788,'0000-00-00 00:00:00',1100,NULL,2),
(7900,'James','Clerk',7698,'0000-00-00 00:00:00',950,NULL,3),
(7902,'Ford','Analyst',7566,'0000-00-00 00:00:00',3000,NULL,2),
(7934,'Miller','Clerk',7782,'0000-00-00 00:00:00',1300,NULL,1);
/*!40000 ALTER TABLE `emp` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2016-01-23 16:27:37
As the last task, you merge all commands into one file. It is therefore advisable to take care of commands that give the correct result in a separate .sql file. This file should have the following format on the content
# Task 1 select * from the dept; # Task 2 select; : : #Task N NB Let each command be a line! don't use "Beautify Query" (it makes harder to control the answers) Select small letters on commands - always. Filed file should be executable in Workbench MySQL admin. That is, a plain text file (not Word) with file extension "* .sql". The file lasts as filing - only .sql files are accepted. You should not deliver the output of the result or anything else.
Item in position 1 1 1 point Show all the columns in the tables "dept". + -------- + ------------ + ---------- + | deptno | dname | loc | + -------- + ------------ + ---------- + | 1 | Accounting | New York | | 2 | Research | Dallas | | 3 | Sales | Chicago | | 4 | Operations | Boston | + -------- + ------------ + ---------- +
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started