Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Oracle 12c SQL Commands

Part of the Oracle 12c For Dummies Cheat Sheet

Thousands of SQL commands exist in the Oracle database realm. Here are some that Database Administrators use daily. This list could differ for each Oracle database you use.

To Do This Use This Command
Create a tablespace CREATE TABLESPACE users
DATAFILE ‘/u01/oracle/oradata/dev12c/users01.dbf’ size 100M
autoextend on next 10M maxsize 4G;
Set up a user CREATE USER ldehoff IDENTIFIED BY ‘welcome1’
DEFAULT TABLESPACE users
QUOTA 10m ON users
PASSWORD EXPIRE;
CREATE ROLE developer_role;
GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE VIEW to developer_role;
GRANT developer_role TO ldehoff;
Create a table CREATE TABLE clients (
client_id NUMBER(4) CONSTRAINT pk_client_id PRIMARY KEY,
last_name VARCHAR2(128) NOT NULL,
first_name VARCHAR2(64) NOT NULL,
acct_number NUMBER(8) CONSTRAINT uk_acct_number UNIQUE,
advisor_id NUMBER(4) CONSTRAINT fk_advisor_id
REFERENCES advisors(advisor_id)
) TABLESPACE users;
Create an index CREATE INDEX idx_last_name ON clients(last_name)
TABLESPACE indexes;
Create a view CREATE OR REPLACE VIEW client_vw AS
SELECT last_name||’,’||first_name “LAST, FIRST”, client_id
FROM clients;
Create a sequence CREATE SEQUENCE client_id_seq
INCREMENT BY 10
START WITH 10;
Use a sequence INSERT INTO clients
VALUES (client_id.nextval, ‘Schumacher’, ‘Michael’, 1000, 1234);
Drop a table DROP TABLE advisors CASCADE CONSTRAINTS;
Flash back to a table FLASHBACK TABLE advisors TO BEFORE DROP;
Join two tables SELECT last_name, acct_number, advisor_last_name
FROM clients JOIN advisors
USING (advisor_id);
Start listener from command line lsnrctl start
Start Enterprise Manager Database Control from command line emctl start dbconsole
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!