Oracle Class Notes

Source: Internet
Author: User
Tags dname

/*
* Create tablespace (as System identity)
*/
CREATE tablespace spc_myself--Table space Name (spc_myself)
DataFile ' E:\datafiles\MYSELF. DBF '--datafile specifies one or more data files for the tablespace, ' path and name of the data file '
Size 30m--file sizes, M-megabyte byte size
Autoextend off--prohibit automatic extension of data files


/*
* Delete Table space
*/
DROP tablespace spc_myself


/*
* Create user
*/
CREATE User one--username (one)
Identified by orcl--password (ORCL)
Default Tablespace spc_myself--for the user to determine the tablespace, not write defaults to the "User table space"


/*
* Delete User
*/
DROP USER one CASCADE;

/*
* Empower Users
*/
GRANT Connect,resource to one;

/*
* Switch Users
*/
--Verify that the user is successfully switched
SELECT * from User_tables;


/*
* Create a table
*/
--Create an EMP table
CREATE TABLE EMP
(
Empno Number (8) Not NULL PRIMARY KEY,
Ename VARCHAR2 (32),
Hirdate DATE,
Sal Number (8,2),
Empic BLOB,
Deptno Number (4)
);

CREATE TABLE Dept
(
Deptno Number (4) Not NULL PRIMARY KEY,
Dname VARCHAR2 (32),
Loc VARCHAR2 (64)
);


/*
* Add sequence
*/
CREATE SEQUENCE sq_dept;
CREATE SEQUENCE sq_emp;

/*
* Add data
*/
BEGIN
For I in 1..100 LOOP
INSERT into Dept VALUES (Sq_dept.nextval, ' pose with ' | | i| | ' Haha ', ' la La ');
END LOOP;
END;

SELECT * FROM Dept;

COMMIT;


DECLARE
CURSOR Dept_list is a SELECT * from dept;
BEGIN
For dept in Dept_list LOOP
For I in 1..100 LOOP
INSERT into emp VALUES (sq_emp.nextval,dept.dname| | ' Office ' | | I,SYSDATE,5000.00,NULL,DEPT.DEPTNO);
END LOOP;
END LOOP;
END;

SELECT * from EMP;

COMMIT;

Oracle Class Notes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.