1、SQL*Plus命令行工具使用:在命令行中输入 sqlplus/nolog 即可启用该工具
    连接到Oracle服务器:conn 用户名/密码 as 连接身份@服务器连接字符串
    连接身份:数据库管理员sysdba,数据库操作员sysyoper,普通用户normal
2、Oracle启动与关闭:在SQL*Plus中,启动Oracle必须是sys用户,命令格式是:startup open,关闭命令:shutdown immediate
3、用户和权限
    一、创建用户:create user 用户名 identified by 口令 [ACCOUNT LOCK|UNLOCK]默认为锁定状态,锁定的用户无法正常登录进行数据库操作
    例:SQL> CREATE USER jerry     IDENTIFIED BY tom   ACCOUNT UNLOCK; alter user gzu_view identified by thinks1314;  修改用户密码
    二、授权:grant 角色|权限 to 用户(角色) 例:GRANT RESOURCE TO jerry;
  

1)grant resource to qcm;--授权角色
            grant create session to qcm; --授予允许登陆
           grant unlimited tablespace to gzu_view; --授予表空间权限,用户使用表空间的权限
         grant select on gzu.COLLEGE_VIEW to gzu_view;--授予指定表查询权限
         grant create table to zhangsan;//授予创建表的权限
   grante drop table to zhangsan;//授予删除表的权限
   grant insert table to zhangsan;//插入表的权限
   grant update table to zhangsan;//修改表的权限
   grant all to public;//这条比较重要,授予所有权限(all)给所有用户(public)
     2)oralce对权限管理比较严谨,普通用户之间也是默认不能互相访问的,需要互相授权
   grant select on tablename to zhangsan;//授予zhangsan用户查看指定表的权限
   grant drop on tablename to zhangsan;//授予删除表的权限
   grant insert on tablename to zhangsan;//授予插入的权限
   grant update on tablename to zhangsan;//授予修改表的权限
   grant insert(id) on tablename to zhangsan;
   grant update(id) on tablename to zhangsan;//授予对指定表特定字段的插入和修改权限,注意,只能是insert和update
     grant alert all table to zhangsan;//授予zhangsan用户alert任意表的权限
     三、撤销权限
     基本语法同grant,关键字为revoke
     四、查看权限
   select * from user_sys_privs;//查看当前用户所有权限
   select * from user_tab_privs;//查看所用用户对表的权限
     五、角色
     角色即权限的集合,可以把一个角色授予给用户
     create role myrole;//创建角色
     grant create session to myrole;//将创建session的权限授予myrole
     grant myrole to zhangsan;//授予zhangsan用户myrole的角色
     drop role myrole;删除角色
   数据库常用角色介绍:
   CONNECT角色,主要应用在临时用户,特别是那些不需要建表的用户,通常只赋予他们CONNECT role。CONNECT是使用Oracle的简单权限,拥有CONNECT角色的用户,可以与服务器建立连接会话(session,客户端对服务器连接,称为会话)。
 RESOURCE角色,更可靠和正式的数据库用户可以授予RESOURCE role。RESOURCE提供给用户另外的权限以创建他们自己的表、序列、过程(procedure)、触发器(trigger)、索引(index)等。
 DBA角色,DBA role拥有所有的系统权限----包括无限制的空间限额和给其他用户授予各种权限的能力。用户SYSTEM拥有DBA角色。
 4、创建表和约束
 创建表:create table ;创建约束: alter table 表名 add constraint 约束名 约束内容。
 create table infos
 (
   stuid varchar2(7) not null,    --学号 学号=‘s’+班号+2位序号 
   stuname varchar2(10) not null,  --姓名
   gender varchar2(2) not null,    --性别  
   age number(2) not null,        --年龄
   seat number(2) not null,        --座号
   enrolldate date,      --入学时间
   stuaddress varchar2(50) default '地址不详',      --住址
   classno varchar2(4) not null    --班号 班号=学期序号+班级序号  
 );
 alter table infos add constraint pk_infos primary key(stuid)  ;--主键
 alter table infos add constraint ck_infos_gender check(gender = '男' or gender = '女')  ;--约束
 alter table infos add constraint ck_infos_seat 
 check(seat >=0 and seat <=50)  ;
 alter table infos add constraint ck_infos_age  
 check(age >=0 and age<=100)  ;
 alter table infos add constraint ck_infos_classno  
 check((classno >='1001' and classno<='1999') or 
 (classno >='2001' and classno<='2999'))  ;
 alter table infos add constraints un_stuname unique(stuname) ;--唯一约束 create table scores
 (
      id number ,        --id  
      term varchar2(2),          --学期 s1或s2
     stuid varchar2(7) not null,     --学号
     examno varchar2(7) not null,      --考号 e+班号+序号  
     writtenscore number(4,1) not null,  --笔试成绩
     labscore number(4,1) not null   --机试成绩
 );
 alter table scores   add constraint ck_scores_term check(term = 's1' or term ='s2');
 alter table scores   add constraint fk_scores_infos_stuid foreign key(stuid) references infos(stuid)  ;--外键sql server中可以使用identify创建自动增长列,但是oracle中的自动增长需要借助序列(sequence)完成