Create and Manage tables

Source: Internet
Author: User

DDL Data Definition language

1 database objects:

A table's basic collection of data stores, consisting of rows and columns.

View extracts logically related data collections from a table,

The sequence provides a regular number.

Indexes improve the efficiency of queries.

Synonyms are aliases to objects.

2 querying which tables the user has established

Select *

From User_tables

3 viewing user-defined various database objects

Select distinct object_type

From User_objects;

4 viewing user-defined tables, views, synonyms, and sequences

Select *

From User_catalog

5 table naming rules

The table name and column name must begin with a letter and must be between 1-30 characters

must contain only uppercase and lowercase letters 0-9 _ $ #

Cannot duplicate a user-defined object

Must not be a reserved word for Oracle

6 Creating a table

Create table

(

Property 1 data type 1

Property 2 data type 2

Property 3 data type 3

Property 4 data type 4

)

The second method relies on other tables to create a table

Create table EMP2

As

Select employee_id id,last_name name,hire_date,salary

From employees;

7alter Table name

Change Table structure

Add ( property name data type)

Modify Modification can modify the data type of a column to an initial value (default value)

But remember, if you have data, you need to delete the data before you modify the column

Drop Column Property

Rename Column Property to new name (rename)

8 additions and deletions can be rolled back (DML can be rolled back)

DDL cannot be rolled back

9 Deleting a table

Drop Table name

Empty the table (not the same as delete)

Truncate table Name (table structure unchanged delete data only)

Change the table name one by one

Rename Old table name to new table name

Create and Manage tables

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.