Oracle basic operations - modified table structure, data CRUD

Create a person table

create table person(
   pid number(20),
   pname varchar2(10)  
);

 

Add a

alter table person add gender number(1);

 

Modify column type

alter table person modify gender char(1);

 

Modify the column name

alter table person rename column gender to sex;

 

To delete a

alter table person drop column sex;

 

Lookup table all records

select * from person;

 

Add a record

insert into person (pid,pname) values (1,'小明');
commit;

 

Delete a record

- All records deleted table in 
the Delete  from the Person;
 - delete tables institutions 
drop  the Table the Person;
 - delete the table, create the table again, the effect is the same as deleting all records 
TRUNCATE  the Table the Person; 
- in the case of large volumes of data, in particular, the index of the table in the case of the operation with high efficiency.

 

Modify a record

update person set pname = '小红' where pid = 1;
commit;

 

Guess you like

Origin www.cnblogs.com/Sm1lence/p/11426027.html