Oracle database, instance name and database are in one-to-one correspondence, oracle server can start multiple instances, corresponding to multiple databases.
The database can be accessed by sqlplus / as sysdba to the instance of the default SID,
View the current instance name: select * from v$instance;
To switch to other instances, you only need to export ORACLE_SID= sidname (instance name), and then enter sqlplus / as sysdba.
When the database already exists, users and user-accessible tablespaces, that is, table structure files for data storage, exist.
1. Oracle TNS listener related:
Check the listener status:
lsnrctl status
Start:
lsnrctl start
Shut down:
lsnrctl stop
Modify the port of the listening file for network client link:
vi /u01/app/oracle/product/11.2.0/network /admin/listener.ora
modify content (HOST = 10.116.4.63)(PORT = 1521)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.116.4.63)(PORT = 1521))
# (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
Modify the listener's SID mapping file:
vi /u01/app/oracle/product/11.2.0/network/admin/tnsnames .ora
add SID is the instance name of jjccbdb:
jjccbdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.116.4.63)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jjccbdb)
)
) Second, Oracle creates/deletes step 1
of the instance library
、Use the dbca tool to silently build a database
dbca -silent -createdatabase -templatename testdb -sid $dbname -gdbname $dbname -datafileDestination $dest -syspassword oracle -systempassword oracle \ -characterset
$langu -redoLogFileSize 512 -storageType FS -emConfiguration NONE -memoryPercentage 30 -totalMemory $mem -automaticMemoryManagement true
2. Use the dbca tool to delete the
existing instance name of the database: SRPSDB
dbca -silent -deleteDatabase -sourcedb SRPSDB -sid SRPSDB -sysDBAUserName sys -sysDBAPassword oracle
3. After the instance is created, set the tablespace and user access permissions
Create temporary tablespace srpsdb_tmp tempfile '/u01/app/oracle/oradata/SRPSDB/srpsdb_tmp.dbf' size 10240m autoextend on next 1024m maxsize 10240m extent management local;
create tablespace srpsdb logging datafile '/u01/app/oracle/oradata/SRPSDB/srpsdb.dbf' size 10240m autoextend on next 1024m maxsize 10240m extent management local;
Create temporary tablespace srpsdb_tmp tempfile '/u01/app/oracle/oradata/jjccbdb/srpsdb_tmp.dbf' size 10240m autoextend on next 1024m maxsize 10240m extent management local;
create tablespace srpsdb logging datafile '/u01/app/oracle/oradata/jjccbdb/srpsdb.dbf' size 10240m autoextend on next 1024m maxsize 10240m extent management local;create user C identified by 123456 default tablespace srpsdb temporary tablespace srpsdb_tmp;
4. Access
create user P identified by 123456 default tablespace srpsdb temporary tablespace srpsdb_tmp;
create user M identified by 123456 default tablespace srpsdb temporary tablespace srpsdb_tmp;
5. Assign roles to users
grant DBA to C;
grant DBA to P;
grant DBA to M;
--- -------------
Three, commonly used oracle view user table and permissions related
User permissions in oracle are divided into system permissions and user table permissions:
View the current user table-level permissions:
select * from user_tab_privs;
View the system permissions owned by the current user:
select * from user_sys_privs;
View the table under the current user:
select * from user_tables ;
View a user's permissions:
select * from dba_sys_privs where grantee='M';
View the user's role, limited to the premise that the current query user is dba:
select * from dba_role_privs where grantee='P';
View the current user's tablespace :
select username, default_tablespace from user_users;
enter dba role to view:
1. sqlplus / as sysdba
2. select owner, table_name from dba_tables where table_name='ABM_ACCOUNT';
Fourth, oracle's jdbc link address: jdbc:oracle:thin:@10.116.4.125:1521:SRPSDB (instance name)