Unlocking the World of Business Intelligence with SQLBI

An Index is a database object that improves the speed of data retrieval. It acts like a pointer to data in a table, allowing queries to be executed more efficiently.
Example:
Creating an index on the EMPLOYEE
table for the LAST_NAME
column:
CREATE INDEX idx_lastname ON EMPLOYEE(LAST_NAME);
A View is a virtual table based on a query that pulls data from one or more tables. It does not store data but provides a way to simplify complex queries.
Example:
Creating a view to display employee details:
CREATE VIEW emp_view AS
SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME FROM EMPLOYEE;
A Sequence is a database object used to generate unique numerical values automatically, often used for primary key generation.
Example:
Creating a sequence starting at 1000, incrementing by 1:
CREATE SEQUENCE emp_seq
START WITH 1000
INCREMENT BY 1;
Using the sequence:
INSERT INTO EMPLOYEE(EMPLOYEE_ID, NAME) VALUES (emp_seq.NEXTVAL, 'John Doe');
A Cluster is a storage mechanism where tables that are frequently joined are physically stored together, optimizing retrieval.
Example:
Creating a cluster:
CREATE CLUSTER emp_dept_cluster (DEPT_ID NUMBER(5));
Creating tables within the cluster:
CREATE TABLE EMPLOYEE (EMP_ID NUMBER, NAME VARCHAR2(50), DEPT_ID NUMBER)
CLUSTER emp_dept_cluster (DEPT_ID);
Granting Permissions allows users to perform specified actions on database objects. Revoking Permissions removes previously granted permissions.
SELECT
, INSERT
, UPDATE
, DELETE
.Granting Example:
Granting SELECT
on the EMPLOYEE
table:
GRANT SELECT ON EMPLOYEE TO user1;
Revoking Example:
Revoking the SELECT
privilege:
REVOKE SELECT ON EMPLOYEE FROM user1;
The DUMP function returns a string that represents the internal data storage of a value.
Example:
SELECT DUMP('Oracle') FROM DUAL;
Output example: Typ=96 Len=6: 79,114,97,99,108,101
A new user can be created using the CREATE USER
command.
CREATE USER new_user IDENTIFIED BY password123;
GRANT CONNECT, RESOURCE TO new_user;
ALTER USER new_user IDENTIFIED BY new_password456;
The SET
command in Oracle SQL*Plus is used to configure various environment settings, like line size, page size, or feedback.
Examples:
SET LINESIZE 100;
SET ECHO OFF;
Spooling allows the output of SQL commands to be written to a file.
Example:
Starting the spool:
SPOOL output.txt;
SELECT * FROM EMPLOYEE;
SPOOL OFF;
This creates a file output.txt
containing the query result.
Comments
Post a Comment