How to identify Duplicates in a table using SQL PLUS
SELECT COUNT(*), COLUMN_A, COLUMN_B
FROM TABLE_B
GROUP BY COLUMN_A, COLUMN_B
HAVING COUNT(*)>1;
How to identify Duplicates in a table using SQL PLUS
SELECT COUNT(*), COLUMN_A, COLUMN_B
FROM TABLE_B
GROUP BY COLUMN_A, COLUMN_B
HAVING COUNT(*)>1;
ORACLE instance started.
Total System Global Area 4731174912 bytes
Fixed Size 2061264 bytes
Variable Size 838863920 bytes
Database Buffers 3875536896 bytes
Redo Buffers 14712832 bytes
ORA-01618: redo thread 2 is not enabled - cannot mount
Details:
The above error will be displayed during the startup of a node in a rac cluster
in the event that a redo thread is not enabled. You need to enable the thread
instance prior to adding a redo log thread which is created using the
ALTER DATABASE ADD LOGFILE THREAD [NUMBER]
The respective instance threads can be identified from the init parameter files
below e.g.:
RACNODE1.THREAD=1 # RACNODE1 instance uses Thread 1
RACNODE2.THREAD=2 # RACNODE2 instance uses Thread 2
Solution:
Enabled the Thread on the active node as follows:
SQL> alter database enable public thread 2;
SQL> select thread#, enabled from v$thread;
THREAD# ENABLED
---------- --------
1 PUBLIC
2 PUBLIC
Restart the node which displays the ORA error
SQL> startup
ORA-29707: inconsistent value 2 for initialization parameter cluster_database_in
stances with other instances
SQL>
SQL>
Details:
In the event that you startup a node on a RAC cluster and you receive an ORA-29707 as above
check "cluster_database" parameter on all nodes in the rac cluster.
SQL> show parameter cluster
NAME TYPE VALUE
------------------------------------ ----------- ----------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
cluster_interconnects string
Note: There is no need to set cluster_database_instances
Solution:
Set cluster_database parameter to true on all nodes of the cluster
SQL> alter system set cluster_database=true;
Table Space Usage
Calculates space usage for all tables in a particular Database , Support 2000 and 2005:
BEGIN try
DECLARE @table_name VARCHAR(500) ;
DECLARE @schema_name VARCHAR(500) ;
DECLARE @tab1 TABLE(
tablename VARCHAR (500) collate database_default
, schemaname VARCHAR(500) collate database_default
);
DECLARE @temp_table TABLE (
tablename sysname
, row_count INT
, reserved VARCHAR(50) collate database_default
, data VARCHAR(50) collate database_default
, index_size VARCHAR(50) collate database_default
, unused VARCHAR(50) collate database_default
);
INSERT INTO @tab1
SELECT t1.name
, t2.name
FROM sys.tables t1
INNER JOIN sys.schemas t2 ON ( t1.schema_id = t2.schema_id );
DECLARE c1 CURSOR FOR
SELECT t2.name + '.' + t1.name
FROM sys.tables t1
INNER JOIN sys.schemas t2 ON ( t1.schema_id = t2.schema_id );
OPEN c1;
FETCH NEXT FROM c1 INTO @table_name;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @table_name = REPLACE(@table_name, '[','');
SET @table_name = REPLACE(@table_name, ']','');
-- make sure the object exists before calling sp_spacedused
IF EXISTS(SELECT OBJECT_ID FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(@table_name))
BEGIN
INSERT INTO @temp_table EXEC sp_spaceused @table_name, false ;
END
FETCH NEXT FROM c1 INTO @table_name;
END;
CLOSE c1;
DEALLOCATE c1;
SELECT t1.*
, t2.schemaname
FROM @temp_table t1
INNER JOIN @tab1 t2 ON (t1.tablename = t2.tablename )
ORDER BY schemaname,tablename;
END try
BEGIN catch
SELECT -100 AS l1
, ERROR_NUMBER() AS tablename
, ERROR_SEVERITY() AS row_count
, ERROR_STATE() AS reserved
, ERROR_MESSAGE() AS data
, 1 AS index_size, 1 AS unused, 1 AS schemaname
END catch
# oslevel
# oslevel -r
# oslevel -q -sTo display man page on oslevel
# man oslevel