SQL statement used to create a table in Oracle

Source: Internet
Author: User

The following SQL statements include:

Create a table and specify the tablespace

Add Table remarks add field remarks

Add Constraints

Add Index

Assign and revoke permissions

 

-- Create Table
Create Table user name. Table Name
(
Field 1 number (19) not null,
Field 2 varchar2 (30) not null,
Field 3 integer not null

)
Tablespace name
Pctfree 10
Initrans 1
Maxtrans 255
Storage
(
Initial 64 K
Next 1 m
Minextents 1
Maxextents Unlimited
);

-- Add Table remarks
Comment on table user name. Table Name Is 'Remarks ';
-- Add field remarks add comments to the columns
Comment on column user name. Table name. Field name is 'Remarks content ';

-- (Constraint) Create/recreate primary, unique and foreign key constraints
Alter table user name. Table Name
Add constraint name primary key (field name) -- here is the primary key
Using Index
Tablespace name
Pctfree 10
Initrans 2
Maxtrans 255
Storage
(
Initial 64 K
Next 1 m
Minextents 1
Maxextents Unlimited
);
-- (INDEX) Create/recreate Indexes
Create index user name. Index name on user name. Table Name (field name)
Tablespace name
Pctfree 10
Initrans 2
Maxtrans 255
Storage
(
Initial 64 K
Next 1 m
Minextents 1
Maxextents Unlimited
);

-- (Assign and revoke permissions) grant/Revoke object privileges
Grant select, insert, update, delete on user name. Table name to utic_busiapp;

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.