Some basic operations in Oracle

 

  Oracle some basic operations, including the operation table space, a user operation, the operation table

. 1  - Create tablespace 
2  Create TABLESPACE itheima
 . 3 datafile ' the I: \ Oracle \ Table \ itheima.dbf ' 
. 4  size 100m
 . 5 AUTOEXTEND ON 
. 6  Next 10m;
 . 7  - delete tablespace 
. 8  drop TABLESPACE itheima;
 . 9  
10  - Creating user 
. 11  Create  user itheima
 12 is IDENTIFIED by itheima
 13 is  default TABLESPACE itheima;
 14  
15  - authorize the user 
16  -oracle database commonly used characters 
. 17 Connect - connection roles 
18 is Resource - developer role 
. 19 dba - Super Administrator role 
20 is  
21 is  - to itheima roles granted dba role 
22 is  Grant dba to itheima;
 23 is  
24  - Switch to the user itheima under 
25  - session-> logoff-> Logon 
26 is  
27  - Create a person table 
28  Create  table person (
 29         PID Number ( 20 is ),
 30         pname VARCHAR2 (10 )  
 31  );
 32  
33 is  
34 is  - modified table structure 
35  - Add a 
36  ALTER  Table Person the Add Gender Number ( . 1 );
 37 [  - type modified column 
38 is  ALTER  Table Person Modify Gender char ( . 1 );
 39  - modified column name 
40  ALTER  Table Person the rename column Gender to Sex;
 41 is  - deleting an 
42 is  ALTER  TablePerson drop  column Sex;
 43 is  
44 is  - the lookup table records 
45  SELECT  *  from Person;
 46 is  - add a record 
47  INSERT  INTO Person (PID, pname) values ( . 1 , ' Bob ' );
 48  the commit ;
 49  - Review a record 
50  Update Person SET pname =  ' colt '  WHERE PID =  . 1 ;
 51 is  the commit ;
52 is  
53 is  - three Delete 
54 is  - delete all records in the table 
55  Delete  from Person;
 56 is  - delete table structure 
57 is  drop  Table Person;
 58  - delete the table, create the table 
59  TRUNCATE  Table Person;
 60  
61 is  - sequence, the default starting from 1, in ascending order, is mainly used to assign a primary key to use 
62  - sequences do not really belong to a table, but the table can be logically and do bindings 
63  - Dual: virtual table, just to make up the full syntax no meaning 
64-  the Create Sequence s_person;
 65  the SELECT s_person.nextval from Dual;
 66  the SELECTs_person.currval from Dual;
 67  
68  - adds a record 
69  INSERT  INTO Person (PID, pname) values (s_person.nextval, ' Bob ' );
 70  the commit ;
 71 is  SELECT  *  from Person;

 

Guess you like

Origin www.cnblogs.com/jyroy/p/11347847.html