日期:2014-05-16  浏览次数:20620 次

解决ORA-01031错误
c:/>show user
USER 为"SCOTT"
c:/>create table te (id number,name varchar2(128),describe varchar2(30));
表已创建。
1.c:/>insert into te select object_id,object_name,'test' from user_objects; 
--最好用sys_objects      行数比较多
c:/>desc user_segments;
 名称                                      是否为空? 类型
 ----------------------------------------- -------- -----------------------
 SEGMENT_NAME                                       VARCHAR2(81)
 PARTITION_NAME                                     VARCHAR2(30)
 SEGMENT_TYPE                                       VARCHAR2(18)
 TABLESPACE_NAME                                    VARCHAR2(30)
 BYTES                                              NUMBER
 BLOCKS                                             NUMBER
 EXTENTS                                            NUMBER
 INITIAL_EXTENT                                     NUMBER
 NEXT_EXTENT                                        NUMBER
 MIN_EXTENTS                                        NUMBER
 MAX_EXTENTS                                        NUMBER
 PCT_INCREASE                                       NUMBER
 FREELISTS                                          NUMBER
 FREELIST_GROUPS                                    NUMBER
 BUFFER_POOL                                        VARCHAR2(7)
2.c:/>select * from user_segments where segment_name like 'TE';
SEGMENT_NAME
---------------------------------------
PARTITION_NAME                 SEGMENT_TYPE       TABLESPACE_NAME
------------------------------ ------------------ -------------------------
     BYTES     BLOCKS    EXTENTS INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS
---------- ---------- ---------- -------------- ----------- -----------
MAX_EXTENTS PCT_INCREASE  FREELISTS FREELIST_GROUPS BUFFER_
----------- ------------ ---------- --------------- -------
TE
                               TABLE              USERS
     65536         16          1          65536                       1
 2147483645                       1               1 DEFAULT
--可能我们的数据会不一样 (blocks,bytes..等 )
--重复执行 1.  用2.查看变化
--大概插入了约600多万行数据时 机器挂了 shutdown 也不好用了  只好重启机器了
--启动后 出现以下情况

SQL> conn sys/sys as sysdba
ERROR:
ORA-01031: insufficient privileges
查看 %oracle_home/NETWORK/ADMIN/sqlnet%  SQLNET.AUTHENTICATION_SERVICES= (NTS) --os认证
--baidu一下
connect / as sysdba is current (Oracle 8i, and later) syntax which replaces the older connect internal syntax, and has exactly the same function.
This syntax is used to connect to the Oracle database with very powerful privileges. In particular, it allows the user to stop and start the database.
When it is used, Oracle does not check the password held for the user in the database's data-dictionary but instead checks that the current operating system userid is defined in the ORA_DBA group (if the OS is Windows NT/2000) or the "dba" group (if the OS is Unix). If the user is in this group, then he is allowed to connect. If he isn't in this group, he will get a ORA-01031: insufficient privileges error message, or an Enter password prompt.
The reason the data dictionary password is not used is that Oracle needs some mechanism of checking that the user is sufficiently authorised to start the database which works even when the database is down. Being a member of this group is sufficient proof that you are authorised to stop and start the database, since only the system administrator (Administrator on Windows, root on Unix) can add users to this group.
The connect / as sysdba technique can therefore be used as a method of logging in as SYS or SYSTEM when you've forgotten both their passwords: Use connect / as sysdba to connect as SYS, (assuming that your operating system userid is in the Windows ORA_DBA or Unix dba group), then change the SYS and SYSTEM passwords. 
--原来远程登录的用户没有在dba用户组中  手动加上就好
SQL> conn sys/sys as sysdba
已连接。
SQL> shutdown immediate
ORA-01109: 数据库未打开

已经