How to create an Oracle database in MySQL database Scott's tables

Source: Internet
Author: User
Tags dname



Let's take a look at the data structures of several tables of Scott users in Oracle:



==============================================================

The following operations are performed in the Oracle database (if required)

==============================================================


To create a table:

CREATE TABLE Dept (deptno INT PRIMARY key,dname varchar, loc VARCHAR (13)); CREATE TABLE EMP (EMPNO int (4) PRIMARY KEY, ename varchar (ten), JOB VARCHAR (9), MGR INT (4), HireDate DATE, SAL DOUBLE , COMM DOUBLE, Deptno int,foreign KEY (deptno) REFERENCES Dept (DEPTNO)); CREATE TABLE salgrade (grade int PRIMARY key,losal int,hisal int);

Insert test data:

insert into dept values  (, ' ACCOUNTING ', ' new york ');insert into dept  values  ("DALLAS");insert into dept values  (' SALES ', ' CHICAGO '); INSERT  INTO dept VALUES  (+, ' OPERATIONS ', ' BOSTON '); Insert into emp values (7369, ' SMITH ', ' Clerk ', 7902,date (' 1980-12-17 '), 800,null,20); Insert into emp values (7499, ' ALLEN ', ' Salesman ', 7698,date (' 1981-2-20 '), 1600,300,30); Insert into emp values (7521, ' WARD ', ' SALESMAN ', 7698,date (' 1981-2-22 '), 1250,500,30) insert into emp values (7566, ' JONES ', ' MANAGER ', 7839,date (' 1981-4-2 '), 2975,null,20) insert into emp values (7654, ' MARTIN ', ' salesman ', 7698,date (' 1981-9-28 ') , 1250,1400,30); Insert into emp values (7698, ' BLAKE ', ' MANAGER ', 7839,date (' 1981-5-1 '), 2850,null,30 ); Insert into emp values (7782, ' CLARK ', ' MANAGER ', 7839,date (' 1981-6-9 '), 2450,null,10); INSERT  into emp vaLues (7788, ' SCOTT ', ' ANALYST ', 7566,date (' 1987-4-19 '), 3000,null,20); Insert into emp values (7839, ' KING ', ' president ', null,date (' 1981-11-17 '), 5000,null,10); Insert into emp values (7844, ' TURNER ', ' Salesman ', 7698,date (' 1981-9-8 '), 1500,0,30); Insert into emp values (7876, ' ADAMS ', ' CLERK ', 7788, DATE (' 1987-5-23 '), 1100,null,20), insert into emp values (7900, ' JAMES ', ' Clerk ', 7698,date (' 1981-12-3 '), 950,null,30), Insert into emp values (7902, ' FORD ', ' ANALYST ', 7566,date (' 1981-12-3 '), 3000,null,20); Insert into emp values (7934, ' MILLER ', ' Clerk ', 7782,date (' 1982-1-23 '), 1300,NULL,10) ; Insert into salgrade values (1,700,1200); Insert into salgrade values (2,1201,1400 ); Insert into salgrade values (3,1401,2000); Insert into salgrade values ( 4,2001,3000); insert into salgrade values (5,3001,9999);



Summary: When creating a table, change the number to Int,varchar2 instead of varchar,datetime to date, and insert the table with the date function.


==============================================================

The following actions are performed on the MySQL user

==============================================================

CREATE TABLE Dept (deptno INT PRIMARY key,dname varchar, loc VARCHAR (13));


CREATE TABLE EMP (EMPNO int (4) PRIMARY KEY, ename varchar (ten), JOB VARCHAR (9), MGR INT (4), HireDate DATE, SAL DOUBLE , COMM DOUBLE, Deptno int,foreign KEY (deptno) REFERENCES Dept (DEPTNO));


CREATE TABLE salgrade (grade int PRIMARY key,losal int,hisal int);



=========================== Inserting Data ===========================

insert into dept values  (' ACCOUNTING ', ' NEW  YORK ');insert into dept values  ("The DALLAS");insert into dept  values  (+, ' SALES ', ' CHICAGO ');insert into dept values  (+, ' OPERATIONS ', ' BOSTON '); 
Insert into emp values (7369, ' SMITH ', ' Clerk ', 7902,date (' 1980-12-17 '), 800,null,20);INSERT  Into emp values (7499, ' ALLEN ', ' salesman ', 7698,date (' 1981-2-20 '), 1600,300,30);insert into  Emp values (7521, ' WARD ', ' salesman ', 7698,date (' 1981-2-22 '), 1250,500,30);insert into emp  VALUES (7566, ' JONES ', ' MANAGER ', 7839,date (' 1981-4-2 '), 2975,null,20); Insert into emp values (7654, ' MARTIN ', ' salesman ', 7698,date (' 1981-9-28 '), 1250,1400,30); Insert into emp values (7698, ' BLAKE ', ' Manager ', 7839,date (' 1981-5-1 '), 2850,null,30); Insert into emp values (7782, ' CLARK ', ' manager ', 7839 , DATE (' 1981-6-9 '), 2450,null,10), Insert into emp values (7788, ' SCOTT ', ' ANALYST ', 7566,date (' 1987-4-19 '), 3000,null,20) insert into emp values (7839, ' KING ', ' president ', null,date (' 1981-11-17 ') ), 5000,null,10); Insert into emp values (7844, ' TURNER ', ' salesman ', 7698,date (' 1981-9-8 '), 1500,0,30 ); Insert into emP values (7876, ' ADAMS ', ' Clerk ', 7788,date (' 1987-5-23 '), 1100,null,20); Insert into emp values ( 7900, ' JAMES ', ' Clerk ', 7698,date (' 1981-12-3 '), 950,null,30), Insert into emp values (7902, ' FORD ', ' ANALYST ', 7566,date (' 1981-12-3 '), 3000,null,20); Insert into emp values (7934, ' MILLER ', ' clerk ', 7782 , DATE (' 1982-1-23 '), 1300,null,10);
INSERT into Salgrade values (1,700,1200), insert into Salgrade values (2,1201,1400), insert into salgrade values ( 3,1401,2000) insert into Salgrade values (4,2001,3000), insert into Salgrade values (5,3001,9999);




This article is from the "Xbc's homepage" blog, so be sure to keep this source http://alipay.blog.51cto.com/7119970/1570488

How to create an Oracle database in MySQL database Scott's tables

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.