`
273514524
  • 浏览: 3223 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

orcle数据库操作

阅读更多
linux oracle 重新启动

linux下重启oracle
[oracle@dbOracle9i ~]$lsnrctl stop             ----------关闭监听
LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 10-OCT-2011 16:19:02

Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
The command completed successfully
[oracle@dbOracle9i ~]$ sqlplus "/as sysdba"        ------sqlplus                  

SQL*Plus: Release 9.2.0.4.0 - Production on Mon Oct 10 16:19:08 2011

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production

SQL> shutdown immediate;            -------关闭数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> start up;
SP2-0310: unable to open file "up.sql"
SQL> startup;                 -------重启数据库
ORACLE instance started.

Total System Global Area  974198740 bytes
Fixed Size                   452564 bytes
Variable Size             402653184 bytes
Database Buffers          570425344 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
SQL> exit                        -------退出sqlplus
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
[oracle@dbOracle9i ~]$ lsnrctl start                ---------打开监听

LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 10-OCT-2011 16:20:08

Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

Starting /home/oracle/product/9.2.0/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 9.2.0.4.0 - Production
System parameter file is /home/oracle/product/9.2.0/network/admin/listener.ora
Log messages written to /home/oracle/product/9.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbOracle9i)(PORT=1522)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 9.2.0.4.0 - Production
Start Date                10-OCT-2011 16:20:08
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  OFF
SNMP                      OFF
Listener Parameter File   /home/oracle/product/9.2.0/network/admin/listener.ora
Listener Log File         /home/oracle/product/9.2.0/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbOracle9i)(PORT=1522)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "lin" has 1 instance(s).
  Instance "oravas", status UNKNOWN, has 1 handler(s) for this service...
Service "oravas" has 1 instance(s).
  Instance "oravas", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@dbOracle9i ~]$
----------------------

1、lsnrctl stop  查看监听
2、sqlplus / as sysdba
   SQL>shutdown immediate;            -------关闭数据库
   SQL>startup;                 -------重启数据库
   SQL>show user;     查看当前用户:
   SQL>show parameter instance_name 查看当前数据库实例:
   SQL> exit                        -------退出sqlplus
3、sql>@full_path/test.sql;
4、添加用户需要两步:
第一步是建立用户:
create user abc                 ----建立个名为abc的用户
identified by abc123;         ----建立密码为abc123;
用户abc已经建立,可以查询用户了。但是没有权限。就是没有使用权,只是有个ABC用户而已。
第二步是给建立的用户授权:
grant connect ,resource,dba to abc;      -------给ABC用户授权,访问权,DBA最高权限;
最后提交:

PL/SQL Developer过程化变成语言
orcle自带客户端工具-sqlplus

数据库SZT
oracle表空间1(大小,物理位置),用于规划数据库表
  table1
  table2
oralce表空间2
  table3
  table4
一、简单操作
1、创建表空间
SQL>create tablespace test datafile 'E:\Database\data\test_data.dbf' size 20M;
2、重命名表空间
SQL>alter tablespace test rename to test_data;
3、创建表
create table student
(
  trandate    CHAR(10),
  ccy         CHAR(3)
) test;
其中test是表空间名字
4、对表结构修改
SQL>alter table student add (class_id number);
SQL>drop table student;删除表
SQL>drop table student cascade constraints;删除表,同时将约束一起删除(当前表主键被其他表用着)
5、查询 group by having
SQL>select distinct name from student where age>21; 剔除重复记录
SQL>select name,age,math from student     //where group by having组合
    where =
    group by name
    having(math>98);
6、排序 order by desc(降)、asc(升 默认)
SQL>select name,age,math from student where =
   order by math desc;
7、先group by,后order by
二、复杂操作 子查询
1、SQL>select * from student //查询里的子查询
       where name in (select name from chengji);
2、SQL>create table tmp_user_objects    //建表子查询
       as select * from user_objects where 1<>1;
3、SQL>insert into tmp_user_objects    //插入语句子查询
       select * from user_objiects
       where object_type='TABLE'
4、联合语句 union(合并剔除重复)、 union all(合并不剔除重复)、intersect(交集)、minus(减去)、
   SQL>select name,age from student
   union all/intersect/minus
   select name,age from tmp_student;
三、连接(多表)
1、自然连接
   SQL>select * from student natural join tmp_student;
2、内连接
   SQL>select * from student inner join tmp_student on name;
四、更新操作
1、SQL>insert into student(name,age,math)
       select name,age,math
       from tmp_student
       where age>20;
2、SQL>update student set age=upper(age),name=upper(name) where  ;

五、oracle中的字符型
1、列的类型:
   character字符型、number数值型、date日期型、LOB大对象
三种字符:char(n)固定长右补齐,varchar(n)可变长不补齐,varchar2(n)可变长不补齐且获得oracle向后兼容的保证

2、PL/SQL声明变量
   字符型函数
lpad()、rpad()、lower()、upper()、initcap()、length()、substr()、instr()、ltrim()、rtrim()、trim()、concat()、translate()、
六、Oracle中的数值型  不建议使用integer
1、列的类型:
   number(16,2)精度16,小数后的位数2
2、PL/SQL声明变量
abs()、round(3.14,1)、ceil(23.45)、floor(23.45)、mod(5,2)、sqrt(4)、power(4,3)、、
   数值型函数
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics