0% found this document useful (0 votes)
83 views2 pages

DBA Cheat Sheet Oracle SQLServer

This document provides a cheat sheet for Oracle and SQL Server commands, including examples of Data Definition Language (DDL) and Data Manipulation Language (DML) operations for creating, altering, and deleting tables. It also covers backup and restore commands for both database systems, as well as indexing and performance analysis techniques. The examples illustrate similar functionalities in both Oracle and SQL Server environments.

Uploaded by

abirshikdar69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views2 pages

DBA Cheat Sheet Oracle SQLServer

This document provides a cheat sheet for Oracle and SQL Server commands, including examples of Data Definition Language (DDL) and Data Manipulation Language (DML) operations for creating, altering, and deleting tables. It also covers backup and restore commands for both database systems, as well as indexing and performance analysis techniques. The examples illustrate similar functionalities in both Oracle and SQL Server environments.

Uploaded by

abirshikdar69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DBA Cheat Sheet - Oracle & SQL Server Commands

1. Oracle SQL Examples

-- DDL
CREATE TABLE employees (
id NUMBER PRIMARY KEY,
name VARCHAR2(100),
department_id NUMBER
);
ALTER TABLE employees ADD email VARCHAR2(100);
DROP TABLE employees;

-- DML
INSERT INTO employees VALUES (1, 'John Doe', 101);
UPDATE employees SET name = 'Jane Doe' WHERE id = 1;
DELETE FROM employees WHERE id = 1;

-- Backup (using RMAN)


RMAN> BACKUP DATABASE;
RMAN> RESTORE DATABASE;

-- Index and Performance


CREATE INDEX idx_dept_id ON employees(department_id);
EXPLAIN PLAN FOR SELECT * FROM employees WHERE department_id = 101;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);

2. SQL Server Examples

-- DDL
CREATE TABLE employees (
id INT PRIMARY KEY,
name NVARCHAR(100),
department_id INT
);
ALTER TABLE employees ADD email NVARCHAR(100);
DROP TABLE employees;

-- DML
INSERT INTO employees VALUES (1, 'John Doe', 101);
UPDATE employees SET name = 'Jane Doe' WHERE id = 1;
DELETE FROM employees WHERE id = 1;

-- Backup & Restore


BACKUP DATABASE MyDB TO DISK = 'C:\backup\[Link]';
RESTORE DATABASE MyDB FROM DISK = 'C:\backup\[Link]';

-- Index and Performance


CREATE INDEX idx_dept_id ON employees(department_id);
SET SHOWPLAN_ALL ON;
GO
SELECT * FROM employees WHERE department_id = 101;
GO
SET SHOWPLAN_ALL OFF;

You might also like