Oracle basic (7) data table, oracle basic data table

Source: Internet
Author: User

Oracle basic (7) data table, oracle basic data table

1. Create a table

Syntax:

Create table [schema.] table

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

Note:

Create table: the keyword used to CREATE a TABLE.

Schema: indicates the owner of the object, that is, the name of the schema. If you create a table in your schema, you can leave the name of the owner unspecified.

Table: The table name.

Column: column name

Datatype indicates the data type and width of the column.

Example:

-- Create table user (id number not null, username varchar2 (20) not null,
Userpass varchar2 (20) not null
)

If you create a user table, the following naming rules must be followed.

1. It indicates that the first letter should be a letter.

2. You cannot use Oracle reserved words to name a table.

3. the maximum length is 30 characters.

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

4. You can use money, numbers, and letters, but not spaces or single quotes.

5. The table name, column name, user name, and other object names in Oracle are case-insensitive. The system automatically converts them to uppercase and lowercase.

 

Ii. modify a table

Alter table: a command to modify the TABLE structure. When you need to add new columns to the original TABLE, modify the original columns, delete the original columns, add constraints, and delete constraints, you can use the alter table command.

Modify the syntax of an existing column:

Alter table <tablename> MODIFY (column definition ...);

Example:

Change the length of the user name and password to 50;

ALTER TABLE t_userMODIFY (username VARCHAR2(50),userpass VARCHAR2(50))

Syntax for adding a new column:

Alter table <tablename> ADD (column definition ...);

Example:

Add phone and address

ALTER TABLE t_userADD (tel VARCHAR2(20),address VARCHAR2(100))

Syntax for deleting existing columns in the table:

Alter table <tablename> drop column colmn;

Example:

Delete phone and address

ALTER TABLE t_userDROP (tel,address)

 

Iii. delete a table

Syntax:

Drop table <tablename>;

Example: delete a user table

Drop table t_user;

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.