Compare SQL Server, Oracle, and DB2 statements for creating and modifying tables! .

Source: Internet
Author: User

The syntax of the create statement is the same, and the data types are different.

However, the syntax for creating a table using subqueries is different.

SQL Server statements created using subqueries:

Select empno, ename, Sal * 12 annsal, hiredate into dept30 from EMP where deptno = 30;

 

Oracle uses query to create a table:

Create Table dept30
Select empno, ename, Sal * 12 annsal, hiredate
From EMP
Where deptno = 30; DB2 uses a query to create a table: 1. create Table dept30 as (select empno, ename, Sal * 12 annsal, hiredate from EMP where deptno = 30) definition only;
2. insert into dept30 select empno, ename, Sal * 12 annsal, hiredate from EMP where deptno = 30;
You can also use this statement in DB2 to repeat the data in tabulation. Copy table: Create Table emp_bak like EMP; statement comparison for modifying tables: Statement for adding columns on SQL SERVER: ALTER TABLE dept30 add Job varchar (9); statement for adding columns on Oracle: alter table dept30 add (job varchar2 (9); statement for adding columns on DB2: alter table dept30 add Job varchar (9); statement for modifying columns on SQL Server: alter table dept30 alter column ename varchar (15); statement for modifying columns on Oracle: alter table dept30 modify (ename varchar2 (15); statement for modifying columns on DB2: D: alter table dept30 alter column ename set data type varchar (15 );
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.