Oracle Client SQLPLUS Tutorial

Oracle roles and permissions: http://blog.csdn.net/bob007/article/details/5871126
Create tablespaces and users: http://blog.csdn.net/starnight_cbj/article/details/6792364
Oracle instances and tables Space, user, database, schema structure and a practical problem:
http://blog.csdn.net/realwar/article/details/5561354
Several concepts of Oracle: database name, global database name, SID, instance, namespace, schema:
http://www.cnblogs.com/ccption/p/3664201.html
Introduction to the three configuration files of ORACLE:
http://www.2cto.com/database/201305/211705.html

There are two ways for sqlplus to connect to oracle
In the first dos environment:
command
sqlplus username/passsword@ip:port/serviceName  as role

Example 1:
sqlplus system/[email protected]:1521/XE  as sysdba

Use the sysdba role and the user system password 123456 to connect to the XE service on the local machine.

Instance 2:
sqlplus system/[email protected]:1521/XE

Connect to the XE service on the local machine with the user system password 123456


Open the sqlplus command line:

command
conn username/passsword@ip:port/serviceName  as role



Example 1:
conn system/[email protected]:1521/XE as sysdba

Use the sysdba role and the user system password 123456 to connect to the XE service on the local machine.

Instance 2:
conn system/[email protected]:1521/XE

Connect to the XE service on the local machine with the user system password 123456.

Instance 3:
conn system/123456 as sysdba

Connect to the local default service


sqlplus related commands:

View the help file:
help index

View the service instance name:
show parameter service;
select name from v$database;

display the current user
show user;

create a table:
create table test (id int,name varchar( 50));


View table structure
desc test;

Insert records:
insert into test values(1,'donald');

Query:
select * from test;

Delete table:
drop table test;

Note:
sqlplus creates a table by default, indicating that the default When we create a table, it shows that the creation is successful, we can insert and desc, but when the query cannot be
found, pay attention to whether it is an uppercase problem; and the table name created by the navicat tool is lowercase


. Look at user:
//Current user's Table
select TABLE_NAME from USER_TABLES where table_name like '%TEST%' ;

//All user tables
select TABLE_NAME from ALL_TABLES where table_name like '%test%' ;

//Include system table
select TABLE_NAME from DBA_TABLES where table_name like '%test%' ;

View users:
//View all users
select * from ALL_USERS;

//View all dba users
select * from DBA_USERS;

//View all users who are not system administrators
select * from DBA_USERS where DEFAULT_TABLESPACE <> 'SYSTEM'


shows the user's
tablespace select tablespace_name from user_tablespaces;
//The administrator uses
select TABLE_NAME from DBA_TABLES where OWNER='sys ';

Summary:
sqlplus creates a table by default, indicating that the default is uppercase. When we create a table, it shows that the creation is successful, can insert, desc, but when the query is not available, pay attention to whether it is a capitalization problem; and the table name created by the navicat tool It is lowercase; Oracle's database exists as an instance, each user corresponds to one or more roles, and each user can only see their own tables; and the sysdba role can see all the tables in the system.


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326946115&siteId=291194637