ORACLE exercises, oracle

Source: Internet
Author: User

ORACLE exercises, oracle
1. Create a new table a with the same table structure and data as emp.


Create table a as select * from emp;

2. Add primary key constraints




Alter table a add constraint pk_a_01 primary key (EMPNO );


3. Add a field 'birthdate' for 'A', type 'date.


Alter table a add (birthdate date );


4. Change the ename field of Table a to fixed-length Text 16. Before modification, transfer the column data, leave the column empty, and then fill the data back.
Answer:


First, change the column name, create a new column named the previous name, copy the data of this field to the new column, and delete the original column.
Alter table a rename column ename to new_ename;
Alter table a add (ename varchar (16 ));
Update a set ename = substr (trim (new_ename), 1, 16 );
Alter table a drop (new_ename );

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.