SQL data definition language

Source: Internet
Author: User
Ii) Data Definition Language 1. Summary The data definition function of SQL is defined for various data objects in the database three-level mode structure. Standard SQL mainly includes tables, views, and indexes, and triggers, cursors, processes, and packages in Oracle. Standard SQL does not support index-defined operations or view modification operations. You can only delete the created method. You can use alter view to modify a view in Orale. 2. statement description 1) create a table, function, and view create table <Table Name> (<column Name> <data type> [column-level integrity constraints] [, <column Name> <data type> [column-level integrity constraints]... [, <Table-level integrity constraints>]); Create Table ABC (A varchar2 <10>, B char <10> ); create view <view Name> [(<column Name> [, <column Name>]...)] as <subquery> [with check option] Create [unique] [cluster] index <index Name> On <Table Name> (<column Name> [<order>] [, <column Name> [<order>]...) [tablespcae tablespace_name]; 2) alter table and function alter table <Table Name> [add <new column Name> <data type> [Integrity Constraint] [drop <Integrity Constraint Name>] [modify <column Name> <data Type>] 3) drop delete D Drop view; drop index. 4) create a table named it_employees, it consists of eight attributes: employee ID, first_name, last_name, email, phone_number, department ID job_id, salary, and department manager ID manager_id. Create Table it_employees (employee_id number (6) Not null unique, first_name varchar2 (20), last_name varchar2 (25) not null, email varchar2 (25), phone_number varchar (20 ), job_id varchar2 (10), salary number (8, 2), manager_id number (6); [Example 2] Create a programmer's view prog_employees (job_id = 'it _ prog '), the column name of the view is hidden. create view prog_employeesasselect employee_id, first_name, last_name, email, phone_number, salary, manager_idfrom it_employeeswhere job_id = 'it _ prog'; [Example 3] run the following create index statement to create an index: create index it_lastname on it_employees (last_name );

[Example 4] Delete the previously created view prog_employees. Drop view prog_employees;

[Example 5] add the "Employee birthday" column to the it_employees table. The data type is "alter table it_employees add birthdate; [Example 6] Change the manager_id field of the it_employees table to eight bits: alter table it_employees modify manager_id number (8); [Example 7] Delete the unique constraint of the employee ID field of the it_employees table: alter table it_employees drop unique (employee_id );

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.