python-Web- database -oracle

1.oracle architecture

-------- global database, this refers to the database (physical structure, a real disk directory) on a physical disk, a general oracle server has 1 Ge global database, file accounts for 1G and more. oracle allows a

-------- one computer to install multiple global database, but this is not recommended. Because a global database can put all the data.

-------- here and mysql is not the same, mysql is free to create a database. A global database comprising N plurality of data files.

-------- users, the oracle which is to isolate the data, MySQL isolating database data units, and oracle unit of user data isolation.

-------- table space is a logical structure, user data is stored in the space table, the data table space is in the data file. Table space may be logically

-------- to the data file into a plurality of regions, each region is a table space. The data file is composed of more than one table space.

-------- data file, which is a global database data files (physical structure, a real disk file). A global database comprising N plurality of data files.

-------- Database Services instance (database instance), is a service process for executing sql command to change to update the data files.

 

-2. Use oracle access data in step

The first 1 : Create table space

- Creating syntax:

create tablespace table space name

datafile ' disk data file address ' size data file size

autoextend on next automatically grow in size

- Examples

create tablespace itheima91

datafile ‘c:\itheima91.dbf’ size 100m

autoextend on next 10m

The first 2 steps: Create a user

- Creating syntax:

create user username identified by password

default tablespace table space name ;

- Examples

create user ith identified by itheima91

default tablespace itheima91;

 

- Use a new user logs to try: the results can not log on, because access is not enough

The first 3 steps: Authorization

- Syntax 1

grant permissions 1, permission 2, ... to the user name ;

- Syntax 2

grant Role 1, Role 2, ... to the user name ;

- role, a role contains multiple permissions

-Oracle system built 3 Ge is, Connect, Resource, dba

------- connect roles, connected to the oracle of authority

------- resource role, operating their own data objects (create your own table, inside the CRUD data), can not operate other user data

------- dba role, the Super Administrator role, the current system is dba. have all privileges

- For convenience, dba given to the user

grant dba to itheima91;

 

------------------------- at itheima91 / itheima91 Sign follows ----------------- --------------------

select * from session_privs; - view the current user belongs to role permissions list, dba has 161 Ge rights

SELECT * FROM USER_ROLE_PRIVS; - view the current user belongs to role

 

3. The management table create, drop, alter

Create table Syntax:

grammar:

create table 表名(

Field 1 Data Type [default Default ]

Field 2 Data type [default Default ]

Field n Data type [default Default ]

);

- Create a person table

create table person(

id number(8) primary key,

name varchar2(100) not null,

gender varchar2(2),

birthday date

);

Table deleted

- mode 1 : Delete table data

delete from person;

- mode 2 : Table Structure removed

drop table person;

 

Table modification

- add a field

alter table person add (address varchar2(100));

- modify the field name

alter table person rename column address to address2;

- modify the field data type

alter table person modify (address2 varchar2(200));

 

Update the table (add, delete, change)

 

4 Data management: the Delete, Update, the SELECT, INSERT INTO

 

- Delete

delete from person where id=2;

 

- Modify

update person set address2=‘东莞’ where id=1;

 

- Query

select * from person;

 

- increase the data

insert into person(id,name,gender,birthday,address2)

values (1, ' John Doe ', ' M ', to_date ( '2018-01-01', 'yyyy-MM-dd HH24: mi: ss'), ' Canton ');

 

insert into person

values (2, ' John Doe ', ' F ', to_date ( '2018-01-01', 'yyyy-MM-dd HH24: mi: ss'), ' Shenzhen ');

-Oracle have mechanisms things, things that need to be submitted for each add, delete, change data manually.

Guess you like

Origin www.cnblogs.com/person1-0-1/p/11390626.html