Common Oracle commands for creating users, tablespaces, and role commands

Source: Internet
Author: User

Common Oracle commands for creating users, tablespaces, and role commands
The following articles mainly introduce how to view the table structure in common Oracle commands. If you are interested in the actual operating solution of how to view the table structure in common Oracle commands, you can view the following articles to better understand them.
EDITDATA table name;
Modify Table fields:
Alter table name modify (field name type constraints );
1. alter table test modify (addd varchar2 (10) null );
Alter table name add (field name type constraints );
1. alter table test add (age varchar2 (5 ));
1. log on to the system user
View the table structure sqlplus in common Oracle commands and enter the system user name and password
Log on to another user
Conn user name/password;
2. Create a tablespace
1. create tablespace space name
2. datafile 'C: \ Space name' size 15 M -- storage path of the tablespace, initial value: 15 M
3. autoExtend on next 10 M -- the automatic increase of space is 10 M
4. permanent online; -- permanent use
3. Create a user
1. create user shi -- create username shi
2. identified by scj -- create a password as scj
3. default tablespace name-default tablespace name
4. temporary tablespace temp -- the temporary tablespace is temp
5. profile default -- restricted by the profile file
6. quota unlimited on tablespace name; -- unlimited table creation under the tablespace
4. Create a role
Create role name identified by password;
5. Authorize a role
Grant create session to role name; -- grant the role the permission to create a session
Grant role name to user name; -- grant role to user
6. grant permissions to users
1. grant connect, resource to shi; -- grant all permissions to shi users
2. Grant dba to shi;-Grant DBA permissions to shi users
3. grant create table to shi; -- grant the shi user the permission to create a table.
7. select table_name from user_tables; view all tables under the current user
8. select tablespace_name from user_tablespaces; view the tablespace of the current user
9. select username from dba_users; view all user name commands must be logged in using sys as sysdba
10. Create a table
Create table Name
1 .(
2. id int not null,
3. name varchar2 (20) not null
4.) tablespace name -- the tablespace to which the table belongs
5. storage
6 .(
7. initial 64 K -- initial Value of the table
8. minextents 1 -- Minimum extension Value
9. maxextents unlimited -- maximum extension Value
10 .);
11. Add primary keys and indexes to the usrs table
1. alter table users
2. add constraint pk primary key (ID );
12. Add Foreign keys to the created users table
1. alter table users
2. add constraint fk_roleid foreign key (roleid)
3. references role (role_id) on delete cascad; -- write the column in the base table below
4. on delete cascad is used to create cascading


 

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.