shopt -s extglob # Enable extended pattern matching
rm -rf !(folder) # Delete everything except the 'folder' directory
shopt -u extglob # Disable extended pattern matching (optional)
shopt -s extglob # Enable extended pattern matching
rm -rf !(folder) # Delete everything except the 'folder' directory
shopt -u extglob # Disable extended pattern matching (optional)
commit: make changes done in transaction permanent.
rollback : rollback the state of database to the last commit point.
savepoint : use to specify a point in transaction to which later you can rollback.
create table student
(
id number primary key,
name varchar2(50),
college varchar2(50)
);
insert all
into student values (1,'pravin','ness')
into student values (2,'prakash','ness')
into student values (3,'pratap','ness')
into student values (4,'pranav','ness')
into student values (5,'prayank','ness')
select * from dual;
--create savepoint student_original --
savepoint student_original;
-- delete some records --
delete student where id=5;
-- rollback to student_original savepoint --
rollback to student_original;
-- most important fact --
you cannot rollback to any previous savepoint once you've triggered commit;
ssh -t -q oracle@pm "(df -h /u02; hostname -f; date)"
read -p "enter server name: " server ; ssh -t -q $server "(sudo -iu oracle)"
or looping multiple servers :-
for servers in server1 server2 server3 server4 ;
do
ssh -t -q $servers "(df -h /u02; hostname -f ; date)" ;
done;
EXPLANATION:-
ssh: This is the SSH command used for secure remote shell access.
-t: This option is used to allocate a pseudo-terminal. It's often necessary when you want to run interactive commands remotely because it simulates an interactive terminal session.
-q: This option stands for "quiet" and is used to suppress warning and diagnostic messages. It makes the SSH command less verbose.
oracle@pm: This part specifies the username (oracle) and the hostname or IP address (pm) of the remote server you want to connect to. The @ symbol separates the username from the hostname.
"(...)": The parentheses enclose a series of commands that you want to execute on the remote server. In this case, three commands are enclosed: df -h /u02, hostname -f, and date.
-t option is essential when running multiple commands, as it ensures that the commands are executed in an environment that behaves like an interactive shell session.
[oracle@pm u02]$ find ./* -type d -name "archivelog" -exec du -sh {} + 2>&1 | grep -v "Permission denied"
(national language support)
nls_sort and nls_comp are parameters used to
control the sorting and comparison behaviour of
characters in SQL queries.
1. NLS_SORT:-
binary-binary sorting (ascii)
french-french linguistic sorting.
german-german linguistic sorting.
spanish-spanish linguistic sorting
binary_ci-binary sorting with case-insensitivity.
french_ci-french linguistic sorting with case-insensitivity.
example:-
alter session set nls_sort='FRENCH';
2. NLS_COMP:-
binary-binary comparison (case-sensitive).
linguistic- linguistic comparison(case-insensitive).
example:-
alter session set nls_comp='LINGUISTIC';overall best for case-insensitive search in SQL oracle:-alter session set nls_sort='binary_ci';alter session set nls_comp='linguistic';select * from nls_database_parameters;select * from nls_instance_parameters;select * from nls_session_parameters;
How to use below:-
&value, &column_name 👉for temporary submission of variable every time you execute a query it'll ask you for entering the value.
&&variable or &&column_name:-
iit's use to set permanent submission in current session;
BIND VARIABLES (:VARIABLE):-
set sqlprompt "_user '@' _connect_identifier > "
The DBMS_SQLTUNE package in Oracle is used for SQL tuning tasks, including recommendations for optimizing SQL statements. You can use it to analyze and tune individual SQL queries or entire SQL workloads. Here's a basic overview of how to use the DBMS_SQLTUNE package to tune a specific SQL query:
Enable the SQL Tuning Advisor:
Before you can use the SQL Tuning Advisor, you need to ensure that it's enabled. You can enable it using the following command as a user with DBA privileges:
sql
Copy code
exec dbms_sqltune.set_tuning_task_parameter('enabled','true');
Create a SQL Tuning Task:
To tune a specific SQL query, you can create a tuning task. You'll need to provide the SQL statement you want to tune as input. You can do this using the DBMS_SQLTUNE.CREATE_TUNING_TASK procedure:
sql
Copy code
Replace 'SELECT * FROM your_table WHERE your_condition' with your actual SQL statement.
You can adjust the time_limit parameter to specify how long the tuning task should run.
Execute the Tuning Task:
After creating the tuning task, you can execute it using the DBMS_SQLTUNE.EXECUTE_TUNING_TASK procedure:
sql
Copy code
Replace 'your_task_name' with the task name returned when you created the tuning task.
Retrieve Tuning Recommendations:
Once the tuning task has completed, you can retrieve tuning recommendations using the DBMS_SQLTUNE.REPORT_TUNING_TASK procedure:
sql
Copy code
This will generate a report with recommendations for improving the SQL query's performance. You can review this report to see suggested actions.
Implement Tuning Recommendations:
Based on the recommendations provided in the report, you can choose to implement changes to your SQL statement, such as creating indexes, rewriting queries, or changing optimizer settings.
Drop the Tuning Task (Optional):
If you no longer need the tuning task, you can drop it using the DBMS_SQLTUNE.DROP_TUNING_TASK procedure:
sql
Copy code
Be sure to clean up tasks when you're done to avoid cluttering the system.
Remember that SQL tuning is an iterative process, and you may need to make multiple adjustments and re-run tuning tasks to achieve the desired performance improvements.
CREATE OR REPLACE DIRECTORY my_dir AS '/path/to/your/directory';
locations:-
windows :-
C:\Users\<username>\.ssh
C:\Users\<username>\.ssh\authorized_keys
C:\Users\<username>\.ssh\id_rsa 👈private key
C:\Users\<username>\.ssh\id_rsa.pub 👈public key
Linux :-
/home/<username>/.ssh
/home/<username>/.ssh/authorized_keys 👈authorized key
/home/<username>/.ssh/id_rsa 👈private key
/home/<username>/.ssh/id_rsa.pub 👈public key
permissions:-
chmod 700 ~/.ssh or chmod 777 /home/<username>/.ssh
chmod 600 ~/.ssh/authorized_keys or chmod 600 /home/<username>/.ssh/authorized_keys
chmod 600 ~/.ssh/id_rsa or chmod 600 /home/<username>/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub or chmdo 644 /home/<username>/.ssh/id_rsa.pub
To generate ssh key on windows and linux
ssh-keygen -t rsa -b 4096 -C "user@gmail.com"
or
ssh-keygen -t rsa
###########################################################################
share your id_rsa.pub key to target server ~/.ssh directory and activate id_rsa private key on source server(your own server/windows)
###########################################################################
for i in {1..10}; do echo | awk -v var=$i '{print var}' ; done
Step 1: Install OpenSSH Server You can do this via PowerShell (run as Administrator ): Check if it's already available: Get-WindowsCapab...