Oracle Foundation (vii) Data sheet

Source: Internet
Author: User

First, create a table

Grammar:

CREATE TABLE [schema.] Table

(column Datatype[,column datatype[,...]);

Description

CREATE TABLE: A keyword for creating tables.

Schema: Represents the owner of the object, which is the name of the schema, and if the user creates the table in his or her own mode, you can not specify the owner's name.

Table: Represents the name of the table

Column: Represents the name of the columns

DataType represents the data type and width of the column.

Example:

-- Membership Form Create Table User (        number not null,        varchar2( null) ,
varchar2 (notnull
)

The above is to create a user table, which indicates that the following naming rules should be followed strictly.

1. Indicate that the first letter should be a letter.

2. You cannot use the Oracle reserved word to name the table.

3. The maximum length indicated is 30 characters.

4. Different tables in the same user mode cannot have the same name.

4. You can use blind spending, numbers and letters, but you can't use spaces and single quotes.

5. The table name, column name, user name, and other object names in Oracle are case-insensitive, and the system is automatically converted to uppercase.

Second, modify the table

ALTER TABLE, in order to modify tables structure commands, you can use the ALTER TABLE directive when you need to add new columns to the original table, modify the original columns, delete the original columns, add constraints, delete constraints, and so on.

To change the syntax of an existing column:

ALTER TABLE <tablename> MODIFY (column definition ...);

Cases:

The length of the modified user name and password is 50;

ALTER TABLE  VARCHAR2(VARCHAR2())

To add a new column syntax:

ALTER TABLE <tablename> ADD (column definition ...);

Cases:

Add Phone and address

ALTER TABLE T_user ADD VARCHAR2 (VARCHAR2(+))

To delete the syntax for an existing column in a table:

ALTER TABLE <tablename> DROP COLUMN colmn;

Cases:

Delete Phone and address

ALTER TABLE T_user DROP (tel,address)

Third, delete the table

Grammar:

DROP TABLE <tablename>;

Example: Deleting a user table

DROP TABLE T_user;

Oracle Foundation (vii) Data sheet

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.