oracle的学习Ⅰ(服务、用户、nvl函数、sysdate函数、记录实验过程)

一、服务开启

net start oracleserviceorcl					// 开启oracle服务
lsnrctl start								// 开启监听服务(listener control)

二、用户

用户名默认口令
sys(超级管理员)change_on_install
systemmanage
scotttiger

sys/change_on_install as sysdba|sysoper					//登陆sys用户
alter user scott identified by tiger account unlock;	// 解锁scott用户
show user;												// 显示当前用户
connect username/password								// 连接用户

三、其他

SQL(structure query language)

类型解释使用对象
DQL数据查询语言select
DDL数据定义语言create、alter、drop
DML数据修改语言insert、update、delete
DCL数据控制语言commit、rollback、grant、revoke

*:代表所有
distinct:去重
||:字符串连接运算符
优先级:not——and——or
别名:as或空格

模糊查询:like %:任意查询 _:一个字符 改运算符效率低
between and(not between and):………与……之间
in(not in):在……里面,不过后面的内容(目标列)只能是一列
is null(is not null):空值查询,且任何值与null运算结果都为null
nvl(param,value):空值处理函数,若param列为空则该列的值为value
sysdate:获取当前的时间函数,默认格式有:yyyy(年),mm(月),dd(日),hh(小时),mi(分),ss(秒),日期类型的数据应该使用引号引起来
order by:排序,asc(默认,升序),desc(降序)
实验过程的记录:spool 文件名 [append]——实验过程——spool off

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C# 访问Oracle示例+PL/SQL+存储过程+触发器 完整示例 测试可用 --PL/SQL基础1 declare begin dbms_output.('不输出不换行'); dbms_output.put_line('输出并换行'); end; --PL/SQL基础2 declare dig number(20,2); begin select avg(price) into dig from products; dbms_output.put_line('电子产品的平均价格是'||dig); end; --PL/SQL基础3 根据产品编号获得产品对象 --pname products.name%type; pname变量的类型与products.name列的类型一样 declare pid constant products.id%type:=1; --定义常量,初值1 pname products.name%type; pdate products.adddate%type; begin --pid:=1; select name,adddate into pname,pdate from products where id=pid; dbms_output.put_line('产品名称是:'||pname||',日期'||pdate); end; --PL/SQL基础4 根据产品编号获得产品对象 --obj products%rowtype; obj与products表的单行类型一样,可以通过点运算取值obj.price declare obj products%rowtype; begin select * into obj from products where id=&编号; dbms_output.put_line('产品名称是:'||obj.name||',价格:'||obj.price); end; --PL/SQL基础5 条件if declare vid products.id%type; vprice products.price%type; begin vid:=&编号; select price into vprice from products where id=vid; if vprice100 and vprice<=1000 then dbms_output.put_line('价格在100—1000之间'); else dbms_output.put_line('价格在1000以上'); end if; end; --PL/SQL基础5 多条件case begin case '&等级' when 'A' then dbms_output.put_line('优秀'); when 'B' then dbms_output.put_line('合格'); when 'C' then dbms_output.put_line('不合格'); end case; end; select id, name, typeid, price, adddate from products create table students( Id int primary key, sex int ) insert into students select 1,1 from dual union select 2,0 from dual union select 3,1 from dual union select 4,0 from dual union select 5,1 from dual insert into students(Id) values(6) select * from students; select translate(translate('1心1意 3心2意','1','一'),'3','三') from dual; select id,nvl(translate(translate(sex,1,'女'),0,'男'),'未知') from students; select id,case as 性别 from( sele

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值