3. Create database, table space, rights Management, tables, constraints, sequences

Source: Internet
Author: User
Tags clear screen sqlplus

One, DOS common commands

Right → Mark → Select what you want to copy → Right click to complete assignment

↑ means looking for the previous code

Data View Log
Time View times
CLS Clear Screen
Exit exits
Regedit registration Form
Taskmgr Task Manager
Compmgmt.msc Computer Management
MSPaint drawing board

Start running Command Collection--------------------------------
Write----------WordPad
Notepad--------Open Notepad
SHRPUBW--------Create a shared folder
Calc-----------Start Calculator
Fsmgmt.msc-----shared Folder Manager

Ii. building space, table, authorization, sequence

--Switch SQL input
Sqlplus/nolog

--Connect to database
Conn System/[email protected]

--Create TABLE space
Create Tablespace tbs_tb07
DataFile ' d:\oracle\product\10.2.0\oradata\TB07\house1.dbf '
Size 20m autoextend on;

--Modify Table space size
ALTER DATABASE datafile ' D:\ORACLE\PRODUCT\10.2.0\ORADATA\TB07\HOUSE1.DBF ' resize 30m;

--Delete the table space without deleting the. dbf Physical File
Drop Tablespace tbs_tb07;

--delete A. dbf physical file when you delete a table empty polygon
Drop tablespace tbs_tb07 including contents and datafiles;

--Query the table space name and status that already exists (note field is dead)
Select Tablespace_name,status from Dba_tablespaces;

--Create User
Create user holly identified by sys default tablespace tbs_tb07 temporary tablespace temp;

--Authorization for users
Grant Connect,resource to Holly;

--Revoke user permissions
Revoke Connect,resource from Holly;

--Exit
Exit

--Re-login
Sqlplus

--Enter user name: Holly
--Enter Password: SYS

--Create a table
CREATE TABLE Stuinfo (ID number not null,name varchar2 (a) Not null,sex varchar2 (2),
Age number);

--Modify Columns
ALTER TABLE Stuinfo Modify (name Varchar2 (20));

--Add columns
ALTER TABLE Stuinfo Add (score number,health number);

--Delete a column
ALTER TABLE stuinfo drop column age;

--Delete multiple columns
ALTER TABLE Stuinfo drop (health,sex);

--View table structure
Desc Stuinfo;

--Delete Table
drop table Stuinfo;

--Set up the above table again

--Create a score table
CREATE TABLE Stuscore (ID number not NULL,SID number is not null,english number (3,2), chain number (3,2), history number (3,2));

--Add Student Exam Time column
ALTER TABLE Stuscore Add (examtime date);
--Add primary key for student information table
ALTER TABLE STUINFO ADD constraint pk_sinfoid primary key (ID);

--Add a primary key to the Student score table
ALTER TABLE Stuscore ADD constraint Pk_ssocreid primary key (ID);

--Add a unique constraint to the Student information table
ALTER TABLE STUINFO add constraint u_name unique (name);

--Add CHECK constraints for student scores table
ALTER TABLE Stuscore add constraint ck_english check (中文版 between 0 and 100);
ALTER TABLE Stuscore add constraint ch_chain check (chain between 0 and 100);
ALTER TABLE Stuscore add constraint ch_history check (history between 0 and 100);

--Adding primary foreign key constraints for student information sheets and student scores tables
ALTER TABLE STUINFO add constraint fk_infoid foreign key (ID) references stuinfo (ID);

--Query constraints
Select Constraint_name,table_name from User_constraints;

--Create a sequence of student information tables
Create sequence Seq_stuinfo;

--Create a sequence of school scores
Create sequence Seq_stuscore;

3. Create database, table space, rights Management, tables, constraints, sequences

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.