Tuesday, August 29, 2023
Wednesday, August 23, 2023
synonyms and views
public synonym:- create public synonym name for scott.students;
private synonym:- create synonym name for scott.students;
public view :- create or replace view name as (select * from scott.students);
Monday, August 21, 2023
tablespace datafiles sizes in KB MB GB TB PB EB ZB YB
select
file_id,
tablespace_name,
file_name,
bytes,
case
when bytes between 0 and 1023 then bytes || ' bytes'
when bytes < power(1024,2) then round(bytes / 1024,4) || ' KB'
when bytes < power(1024,3) then round(bytes / power(1024,2),4) || ' MB'
when bytes < power(1024,4) then round(bytes / power(1024,3),4) || ' GB'
when bytes < power(1024,5) then round(bytes / power(1024,4),4) || ' TB'
when bytes < power(1024,6) then round(bytes / power(1024,5),4) || ' PB'
when bytes < power(1024,7) then round(bytes / power(1024,6),4) || ' EB'
when bytes < power(1024,8) then round(bytes / power(1024,7),4) || ' ZB'
when bytes < power(1024,9) then round(bytes / power(1024,8),4) || ' YB'
else 'INVALID VALUE FOR BYTES'
end as bytes_sizes
from dba_data_files;
select(select host_name from v$instance) "Host",(select instance_name from v$instance) "Instance",owner,segment_name,(selectto_char(cast(created as timestamp with local time zone), 'DD-MONTH-YYYY hh24:mi:ss TZD yyyy') "created" from dba_objects where object_name='&object_name' and owner='&schema_name') "created",(select to_char( cast(sysdate as timestamp with local time zone), 'DD-MONTH-YYYY hh24:mi:ss TZD yyyy') from dual) "sysdate",casewhen bytes between 0 and 1023 then bytes || 'bytes'when bytes < power(1024,2) then round(bytes / power(1024,1),4) || 'KB'when bytes < power(1024,3) then round(bytes / power(1024,2),4) || 'MB'when bytes < power(1024,4) then round(bytes / power(1024,3),4) || 'GB'when bytes < power(1024,5) then round(bytes / power(1024,4),4) || 'TB'when bytes < power(1024,6) then round(bytes / power(1024,5),4) || 'PB'when bytes < power(1024,7) then round(bytes / power(1024,6),4) || 'EB'when bytes < power(1024,8) then round(bytes / power(1024,7),4) || 'ZB'when bytes < power(1024,9) then round(bytes / power(1024,8),4) || 'YB'else 'INVALID VALUE FOR BYTES'end as bytes_sizesfrom dba_segmentswhere segment_name='&table_name' and owner='schema_name';
select tablespace_name,warning_value,critical_value from dba_tablespace_thresholds where tablespace_name=upper('&tablespace_name');important views in oracledba_tablespace_thresholdsdba_thresholdsdba_triggersdba_ts_quotasall_apply_quotasall_apply_errorall_certificatesall_goldengate_privilegesall_goldengate_ruleall_goldengate_inboundall_lobsall_method_paramsall_external_locationsall_credentials
Friday, August 18, 2023
Apache httpd tomcat Server setup on linux
1. dnf install httpd; dnf install apache*
2. systemctl enable --now httpd.service
3.sestatus --> /etc/selinux/config ---> set selinux=permissive
4. if possible :-
systemctl stop firewalld.service
systemctl disable firewalld.service
or
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
go to chrome/edge:-
http://pm
it will show you the html file from :-
/etc/httpd/conf/httpd.conf
/var/www/html/index.html (you need to create and add your html content)
logs:-
var/log/httpd
when you change/modify "/var/www/html/index.html" do : systemctl restart httpd
Thursday, August 17, 2023
oracle errors and how to resolve them
fix for ORA-03113 end-of-file on communication channel:-
1. SQLPLUS / AS SYSDBA
2. startup mount;
SQL> alter database clear unarchived logfile group 1;
Database altered.
SQL> alter database clear unarchived logfile group 2;
Wednesday, August 16, 2023
File Automation Script
echo "Enter file name: "
read file
if test -e ${file}
then
select user in empty directory readable writable
do
case ${user} in
"empty")
if test -s ${file}
then
echo "${file}-->is not empty"
else
echo "${file}-->is empty"
fi
;;
"directory")
if test -d ${file}
then
echo "${file}-->is a directory"
else
echo "${file}-->is not a directory"
fi
;;
"readable")
if test -r ${file}
then
echo "${file}-->is readable"
else
echo "${file}-->is not readable"
fi
;;
"writable")
if test -w ${file}
then
echo "${file}-->is writable"
else
echo "${file}-->is not writable"
fi
;;
"executable")
if test -x ${file}
then
echo "${file}-->is executable"
else
echo "${file}-->is not executable"
fi
;;
esac
done
else
echo "${file}-->not found"
fi
database link in oracle database
Make sure we have database entries of target db in tnsnames.ora
------------------------------------------------------------------
CONNECT TO username IDENTIFIED BY password
USING 'remote_database_tns';
CREATE PUBLIC DATABASE LINK link_name
CONNECT TO username IDENTIFIED BY password
USING 'tns_string';
SELECT * FROM remote_table@remote_db_link;
Saturday, August 12, 2023
How to find same columns in multiple tables/views
How to find same columns in multiple tables/views
********************************************************
col column_name for a20;
select
a.table_name,a.column_name,
b.table_name,b.column_name,
c.table_name,c.column_name
from
(select * from all_tab_columns where table_name='DBA_DATA_FILES') a
inner join
(select * from all_tab_columns where table_name='DBA_FREE_SPACE') b
on a.column_name=b.column_name
inner join
(select * from all_tab_columns where table_name='DBA_EXTENTS') c
on b.column_name=c.column_name;
*************************************************************
TABLE_NAME COLUMN_NAME TABLE_NAME COLUMN_NAME TABLE_NAME COLUMN_NAME
-------------------- -------------------- -------------------- -------------------- -------------------- --------------------
DBA_DATA_FILES FILE_ID DBA_FREE_SPACE FILE_ID DBA_EXTENTS FILE_ID
DBA_DATA_FILES TABLESPACE_NAME DBA_FREE_SPACE TABLESPACE_NAME DBA_EXTENTS TABLESPACE_NAME
DBA_DATA_FILES BYTES DBA_FREE_SPACE BYTES DBA_EXTENTS BYTES
DBA_DATA_FILES BLOCKS DBA_FREE_SPACE BLOCKS DBA_EXTENTS BLOCKS
DBA_DATA_FILES RELATIVE_FNO DBA_FREE_SPACE RELATIVE_FNO DBA_EXTENTS RELATIVE_FNO
***********************************************************************************
-------------------------------
col table_name for a20;
col column_name for a20;
select
a.table_name,a.column_name,
b.table_name,b.column_name,
c.table_name,c.column_name
from
(select * from all_tab_columns where table_name = upper('&table_a')) a
inner join
(select * from all_tab_columns where table_name = upper('&table_b')) b
on a.column_name=b.column_name
inner join
(select * from all_tab_columns where table_name = upper('&table_c')) c
on b.column_name=c.column_name;
******************************************************
Friday, August 11, 2023
dd ---> data duplication command powerful command to manipulate copying " dd if=first.txt of=second.txt"
dd [if=input_file] [of=output_file] [bs=block_size] [count=num_blocks]
if: Specifies the input file. This can be a regular file, a device (e.g.,/dev/sda), or other data source. If not provided,ddwill use standard input.of: Specifies the output file. This can be a regular file, a device, or other data destination. If not provided,ddwill use standard output.bs: Sets the block size for data transfer. You can specify values like 1K, 4M, etc.count: Specifies the number of blocks to copy.skip: Skips a specified number of blocks before starting to copy data.seek: Skips a specified number of blocks in the output file before writing data.conv: Used for data conversion, such as changing the character encoding or converting uppercase to lowercase.status: Shows the progress of theddcommand.
Wednesday, August 9, 2023
Create tablespace In Oracle database
Important Facts in Oracle:- physical structures:- data files, redo log files, archive log files, control files, parameter files, etc. logical structures:- tablespaces, extents, segments, etc. if you wish to see some visible content in physical files like data files, etc. $ strings system01.dbf Schemas ---> Take it as 'Container of all Objects created by a User in Database' Objects:- tables, procedures, functions, views, packages, etc. packages:- optimized collection of objects or say ease to access objects SYSTEM tablespace: This tablespace is created when the database is created and contains the data dictionary, which stores information about the database objects, such as tables, indexes, and constraints. The SYSTEM tablespace is used by the database itself, and it should not be used for storing user data. SYSAUX tablespace: This tablespace is used to store system-related metadata and noncritical system data. It includes components such as the Automatic Workload Repository (AWR), Oracle Text, and Oracle Spatial. This tablespace is created automatically when the database is created, and it is recommended to leave the SYSAUX tablespace as it is. TEMP tablespace: This tablespace is used to store temporary data that is generated during query execution, sorting, and joining. The TEMP tablespace is used by the database for performing operations that require large amounts of temporary storage. It is recommended to create a separate TEMP tablespace for each Oracle instance to improve performance. UNDO tablespace: This tablespace is used to store undo information, which is used to roll back changes made to the database. The UNDO tablespace is used by the database to support transactions and provides a way to recover the database to a previous state. It is recommended to create a separate UNDO tablespace for each Oracle instance to improve performance. USERS tablespace: This tablespace is used to store user data such as tables, indexes, and other objects. The USERS tablespace is created by default, and it is recommended to create additional tablespaces for storing user data to manage data growth and improve performance. INDEX tablespace: This tablespace is used to store indexes that are created on user tables. It is recommended to create separate INDEX tablespaces to improve performance by separating index data from user data. LOB tablespace: This tablespace is used to store Large Object (LOB) data such as images, videos, and other large files. It is recommended to create a separate LOB tablespace for each table that contains LOB data to improve performance and manage data growth.
--- To create temporary tablespace
CREATE TEMPORARY TABLESPACE temp_ts
TEMPFILE '/path/to/tempfile/temp01.dbf'
SIZE 100M REUSE
AUTOEXTEND ON NEXT 10M
MAXSIZE UNLIMITED;
--- To create undo tablespace
CREATE undo TABLESPACE undo_ts
datafile '/path/to/undofile/undo01.dbf'
SIZE 100M REUSE
AUTOEXTEND ON NEXT 10M
MAXSIZE UNLIMITED;
--- To create users tablespace
CREATE TABLESPACE users_ts
datafile '/path/to/usersfile/users01.dbf'
SIZE 100M REUSE
AUTOEXTEND ON NEXT 10M
MAXSIZE UNLIMITED;
--- To create system tablespace
CREATE TABLESPACE system_ts
datafile '/path/to/systemfile/system01.dbf'
SIZE 100M REUSE
AUTOEXTEND ON NEXT 10M
MAXSIZE UNLIMITED;
--- To create sysaux tablespace
CREATE TABLESPACE sysaux_ts
datafile '/path/to/sysauxfile/sysaux01.dbf'
SIZE 100M REUSE
AUTOEXTEND ON NEXT 10M
MAXSIZE UNLIMITED;
--- To create LOB tablespace (stores large objects like BLOBs, CLOB, etc)
CREATE TABLESPACE lob_ts
TEMPFILE '/path/to/lobfile/lob01.dbf'
SIZE 100M REUSE
AUTOEXTEND ON NEXT 10M
MAXSIZE UNLIMITED;
Create Linux Command Using "/usr/sbin" system executable (commands)
ln -s /path/to/shell_script.sh /usr/sbin/your_command_name
opatchauto
# Log in as root su - root # Execute opatchauto against the unzipped patch directory /u01/app/19.0.0/ grid /OPatch/opatchauto apply /tmp/pat...
-
Executing Result Cache flush and UTLRP Result Cache flush: generally result cache flush done on the database to flush the buffer to rem...
-
2. To delete all files with the exception of filename1 and filename2: $ rm -v !("filename1"|"filename2") *************...