方法1:
sqlplus sjtu/sjtu@'(description=(address_list=(address=(protocol=tcp)(host=192.168.0.77)(port=1521)))(connect_data=(service_name=SJTU)))'
如下图所示:
方法2:
sqlplus sjtu/sjtu@192.168.0.77:1521/SJTU
如下图所示:
3.连接格式
方法1中的格式是固定的,我们在oralce的安装目录搜索tnsnames.ora.sample即可找到相应格式,如下列代码所示:
# This is a sample tnsnames.ora that contains the NET8 parameters that are # needed to connect to an HS Agent dg4odbc = (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)) (CONNECT_DATA=(SID=dg4odbc)) (HS=OK) )
4.以sysdba身份登录
C:\Users\xuwei>sqlplus /nolog SQL> conn / as sysdba SQL> select name from v$database; NAME --------- ORCL SQL> select * from global_name; GLOBAL_NAME -------------- ORCL