Create an Oracle learning table in MySQL

Source: Internet
Author: User

The java journey finally arrived at JDBC. Before learning JDBC, I had to review the database. I downloaded the textbooks of Shang xuexiang Oracle on the Internet, and I could only install mysql on my local machine, so I want to create an oracle learning table in mysql. The bill is still successful.

When creating a table, replace NUMBER with int, varchar2 with varchar, datetime with date, and use the DATE function when inserting the table.

1. Create a database
Create database mydata;

2. Use the database
USE mydata

3. Create dept and emp tables
// Create a dept table
Create table dept
(
Deptno int primary key,
Dname VARCHAR (14 ),
Loc VARCHAR (13)
);
// Create an emp table
CREATE TABLE EMP
(Empno int (4) primary key,
Ename varchar (10 ),
Job varchar (9 ),
Mgr int (4 ),
Hiredate date,
Sal double,
Comm double,
Deptno INT,
Foreign key (deptno) REFERENCES dept (deptno)
);
// Create a salgrade table
Create table salgrade (
Grade int primary key,
Losal INT,
Hisal INT
)

4. insert data
INSERT INTO DEPT VALUES
(10, 'accounting', 'New YORK ');
Insert into dept values (20, 'Research ', 'Dallas ');
INSERT INTO DEPT VALUES
(30, 'sales', 'Chicago ');
INSERT INTO DEPT VALUES
(40, 'operations', 'boston ');
INSERT INTO EMP VALUES
(7369, 'Smith ', 'cler', 7902, DATE ('2017-12-17'), 1980, NULL, 20 );
INSERT INTO EMP VALUES
(7499, 'allen', 'salesman', 7698, DATE ('2017-2-20 '), 1981, 30 );
INSERT INTO EMP VALUES
(7521, 'ward ', 'salesman', 7698, DATE ('2017-2-22 '), 1981, 30 );
INSERT INTO EMP VALUES
(7566, 'Jones ', 'manager', 7839, DATE ('2017-4-2'), 1981, NULL, 20 );
INSERT INTO EMP VALUES
(7654, 'martin ', 'salesman', 7698, DATE ('2017-9-28 '), 1981, 30 );
INSERT INTO EMP VALUES
(7698, 'bucke', 'manager', 7839, DATE ('2017-5-1 '), 1981, NULL, 30 );
INSERT INTO EMP VALUES
(7782, 'clark', 'manager', 7839, DATE ('2017-6-9 '), 1981, NULL, 10 );
INSERT INTO EMP VALUES
(7788, 'Scott ', 'analyst', 7566, DATE ('2017-4-19'), 1987, NULL, 20 );
INSERT INTO EMP VALUES
(7839, 'King', 'President ', NULL, DATE ('2017-11-17'), 1981, NULL, 10 );
INSERT INTO EMP VALUES
(7844, 'turner ', 'salesman', 7698, DATE ('2017-9-8 '), 1981, 0, 30 );
INSERT INTO EMP VALUES
(7876, 'adams', 'cler', 7788, DATE ('2017-5-23 '), 1987, NULL, 20 );
INSERT INTO EMP VALUES
(7900, 'James ', 'cler', 7698, DATE ('2017-12-3'), 1981, NULL, 30 );
INSERT INTO EMP VALUES
(7902, 'Ford ', 'analyst', 7566, DATE ('2017-12-3'), 1981, NULL, 20 );
INSERT INTO EMP VALUES
(7934, 'miller ', 'cler', 7782, DATE ('2017-1-23'), 1982, NULL, 10 );
Insert into salgrade VALUES (1,700,120 0)
Insert into salgrade VALUES (1400)
Insert into salgrade VALUES (2000)
Insert into salgrade VALUES (4,2001, 3000)
Insert into salgrade VALUES (5, 3001, 9999)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.