Welcome to the website navigation,本站只接受合法正规的企业网站,欢迎站长们提交你的网站获得展示和流量有任何问题请联系站长,欢迎大家加入本站。

                
提交网站
  • 网站:76083
  • 待审:5
  • APP:577
  • 文章:304411
  • 会员:56004
文字内链包年1000元 文字内链包年1000元 文字内链包年1000元 AI办公网站 AI绘画工具 AIchat

名站网址导航为大家提供关于数据库教程相关的教程网站知识。

Oracle网站数据库基本经常用的开始执行命令汇总uQDAIChat_企业网址导航_网址分类目录_企业黄页网址提交查询专业网站!

1、得到网站数据库名和创建日期 SELECT name, created, log_mode, open_mode FROM v$database;,2、ORACLE网站数据库的计算机的主机名,ORACLE网站数据库的实例名及ORACLE网站数据库管理系统的版本信息 SELECT host_name, instance_name, version FROM v,3、为了知道oracle网站数据库版本的一些特殊信息 select * from v$version;,4、获取控制网站网站文件名字 select * from v$controlfile;,5、得到Oracle网站数据库的重做日志配置信息 SELECT group#, members, bytes, status, archived FROM v$log; select GROUP#,MEM,6、获取oracle的每个重做日志(成员)网站网站文件所存放的具体位置 select * from v$logfile;,7、知道ORACLE网站数据库的备份和恢复策略和归档网站网站文件的具体位置 archive log list,8、知道ORACLE网站数据库中到底有多少表空间以及每个表空间的状态 select tablespace_name, block_size, status, contents, logging from ,9、知道每个表空间存在哪个磁盘上以及网站网站文件的名字等信息 SELECT file_id, file_name, tablespace_name, status, bytes from dba_data_f,10、知道Oracle网站数据库系统上到底有多少用户和都是什么时候创建的 select username,created from dba_users; select username, DEFAULT_,11、从控制网站网站文件中取出信息涉及到以下一些相关的开始执行命令,复制具体相关代码 具体相关代码如下:,select * from v$archived select * from v$archived_log select * from v$backup select * from v$databas,复制具体相关代码 具体相关代码如下:,MAXDATAFILES MAXINSTANCES MAXLOGFILES MAXLOGhISTORY MAXLOGMEMBERS,14、假如如果您的显示被分成了两部分,您需要使用类似于set pagesize 100的SQL*Plus开始执行命令先格式化输出。有关的格式化输出开始执行命令有以下这些: record_size:  为每个记录的字节数。,15、知道控制网站网站文件中的所有数据网站网站文件(DATAFILE),表空间(TABLESPACE),和重做日志(REDO LOG)所使用的记录情况 SELECT type, record_size, record,16、获取控制网站网站文件名字 select value from v$parameter where name ='control_files'; 或者:select * from v$controlfil,17、如何在一个已经安装的Oracle网站数据库中添加或移动控制网站网站文件呢? 以下是在一个已经安装的Oracle网站数据库中添加或移动控制网站网站文件的具体步骤:,a、利用数据字典v$controlfile来获取现有控制网站网站文件名字。,b、正常关闭Oracle网站数据库。,c、将新的控制网站网站文件名添加到参数网站网站文件的CONTROL_FILES参数中。,d、使用操作办法系统的复制开始执行命令将现有控制网站网站文件复制到指定位置。,e、重新启动Oracle网站数据库。,f、利用数据字典v$controlfile来验证新的控制网站网站文件名字是否正确。,g、假如如果有误重做上述操作办法,假如如果无误删除无用的旧控制网站网站文件。,
SQL> 对于表的操作办法: 创建表,修改表(添加新的列,改变当前某些列,删除列),删除表
SQL> 创建表: create table(需要create table的权限)
SQL> 修改表: alter table tablename add/modify/drop
SQL> 删除表:drop table tablename
SQL> */
SQL> show user;
USER 为 "SCOTT"
SQL> --访问hr用户下的表
SQL> select * from hr.employees;
select * from hr.employees
                 *
第 1 行出现错误:
ORA-00942: 表或视图不存在
SQL> --测试defaul值
SQL> create table test1
  2  (tid number,
  3   tname varchar(20),
  4   hiredate date default sysdate);
表已创建。
SQL> insert into test1(tid,tname) values(1,'Mary');
已创建 1 行。
SQL> select * from test1;
       TID TNAME                hIREDATE                                                                               
---------- -------------------- --------------                                                                         
         1 Mary                 12-6月 -11                                                                             
SQL> --rowid rownum都是伪列
SQL> select rowid,rownum,empno from emp;
ROWID                  ROWNUM      EMPNO                                                                               
------------------ ---------- ----------                                                                               
AAANA2AAEAAAAAsAAT          1       1122                                                                               
AAANA2AAEAAAAAsAAO          2       1234                                                                               
AAANA2AAEAAAAAsAAP          3       1235                                                                               
AAANA2AAEAAAAAsAAQ          4       2222                                                                               
AAANA2AAEAAAAAsAAR          5       2345                                                                               
AAANA2AAEAAAAAsAAS          6       2346                                                                               
AAANA2AAEAAAAAsAAA          7       7369                                                                               
AAANA2AAEAAAAAsAAB          8       7499                                                                               
AAANA2AAEAAAAAsAAC          9       7521                                                                               
AAANA2AAEAAAAAsAAD         10       7566                                                                               
AAANA2AAEAAAAAsAAE         11       7654                                                                               
ROWID                  ROWNUM      EMPNO                                                                               
------------------ ---------- ----------                                                                               
AAANA2AAEAAAAAsAAF         12       7698                                                                               
AAANA2AAEAAAAAsAAG         13       7782                                                                               
AAANA2AAEAAAAAsAAh         14       7788                                                                               
AAANA2AAEAAAAAsAAI         15       7839                                                                               
AAANA2AAEAAAAAsAAJ         16       7844                                                                               
AAANA2AAEAAAAAsAAK         17       7876                                                                               
AAANA2AAEAAAAAsAAL         18       7900                                                                               
AAANA2AAEAAAAAsAAM         19       7902                                                                               
AAANA2AAEAAAAAsAAN         20       7934                                                                               
已选择20行。
SQL> --rowid:oracle维护一个地址,该地址指向了该行在硬盘上实际存储的位置
SQL> --关于varchar2和char
SQL> create table testchar
  2  ( c char(5),
  3    v varchar(5));
表已创建。
SQL> insert into testchar values('a','b');
已创建 1 行。
SQL> select * from testchar;
C     V                                                                                                                
----- -----                                                                                                            
a     b                                                                                                                
SQL> select concat(c,'#'),concat(v,'#') from testchar;
CONCAT CONCAT                                                                                                          
------ ------                                                                                                          
a    # b#                                                                                                              
SQL> --添加新列
SQL> alter table testchar
  2  add  hiredate date;
表已更改。
SQL> desc testchar;
 名称                                                              是否为空? 类型
 ----------------------------------------------------------------- -------- --------------------------------------------
 C                                                                          ChAR(5)
 V                                                                          VARChAR2(5)
 hIREDATE                                                                   DATE
SQL> --修改表
SQL> alter table testchar
  2  modify c char(10);
表已更改。
SQL> desc testchar;
 名称                                                              是否为空? 类型
 ----------------------------------------------------------------- -------- --------------------------------------------
 C                                                                          ChAR(10)
 V                                                                          VARChAR2(5)
 hIREDATE                                                                   DATE
SQL> --删除列
SQL> alter table testchar
  2  drop hiredate;
drop hiredate
     *
第 2 行出现错误:
ORA-00905: 缺失关键字
SQL> ed
已写入 file afiedt.buf
  1  alter table testchar
  2* drop column hiredate
SQL> /
表已更改。
SQL> desc testchar;
 名称                                                              是否为空? 类型
 ----------------------------------------------------------------- -------- --------------------------------------------
 C                                                                          ChAR(10)
 V                                                                          VARChAR2(5)
SQL> host cls
SQL> --删除表
SQL> select * from tab;
TNAME                          TABTYPE  CLUSTERID                                                                      
------------------------------ ------- ----------                                                                      
DEPT                           TABLE                                                                                   
EMP                            TABLE                                                                                   
BONUS                          TABLE                                                                                   
SALGRADE                       TABLE                                                                                   
EMP10                          TABLE                                                                                   
EMP101                         TABLE                                                                                   
TEST1                          TABLE                                                                                   
BIN$gNM24ey8RKW0vjhtZ7ZFsA==$0 TABLE                                                                                   
TESTDELETE                     TABLE                                                                                   
TESTChAR                       TABLE                                                                                   
已选择10行。
SQL> drop table testdelete;
表已删除。
SQL> select * from tab;
TNAME                          TABTYPE  CLUSTERID                                                                      
------------------------------ ------- ----------                                                                      
DEPT                           TABLE                                                                                   
EMP                            TABLE                                                                                   
BONUS                          TABLE                                                                                   
SALGRADE                       TABLE                                                                                   
EMP10                          TABLE                                                                                   
EMP101                         TABLE                                                                                   
TEST1                          TABLE                                                                                   
BIN$gNM24ey8RKW0vjhtZ7ZFsA==$0 TABLE                                                                                   
TESTChAR                       TABLE                                                                                   
BIN$aJrS9iffT4O1GcD0h3fepg==$0 TABLE                                                                                   
已选择10行。
SQL> --使用purge参数彻底删除表
SQL> drop table test1 purge;
表已删除。
SQL> select * from tab;
TNAME                          TABTYPE  CLUSTERID                                                                      
------------------------------ ------- ----------                                                                      
DEPT                           TABLE                                                                                   
EMP                            TABLE                                                                                   
BONUS                          TABLE                                                                                   
SALGRADE                       TABLE                                                                                   
EMP10                          TABLE                                                                                   
EMP101                         TABLE                                                                                   
BIN$gNM24ey8RKW0vjhtZ7ZFsA==$0 TABLE                                                                                   
TESTChAR                       TABLE                                                                                   
BIN$aJrS9iffT4O1GcD0h3fepg==$0 TABLE                                                                                   
已选择9行。
SQL> --oracle的回收站
SQL> --查看回收站
SQL> show recyclebin;
ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME                                                 
---------------- ------------------------------ ------------ -------------------                                       
TESTDELETE       BIN$aJrS9iffT4O1GcD0h3fepg==$0 TABLE        2011-06-12:15:43:34                                       
TESTDELETE       BIN$gNM24ey8RKW0vjhtZ7ZFsA==$0 TABLE        2011-06-12:14:51:43                                       
SQL> --清空回收站
SQL> purge recyclebin;
回收站已清空。
SQL> show recyclebin;
SQL> --关于约束:
SQL> --创建一个表,包含所有约束
SQL> create table myuser
  2  ( userID number constraint pk primary key,
  3    username varchar2(20) constraint c_name not null,
  4    gender   varchar2(2)  constraint c_gender check (gender in ('男','女')),
  5    email    varchar2(20) constraint c_email1 not null
  6                          constraint c_email2 unique
  7    deptno   number constraint fk refereneces dept(deptno)
  8  );
  deptno   number constraint fk refereneces dept(deptno)
  *
第 7 行出现错误:
ORA-00907: 缺失右括号
SQL>   create table myuser
  2  ( userID number constraint pk primary key,
  3    username varchar2(20) constraint c_name not null,
  4    gender   varchar2(2)  constraint c_gender check (gender in ('男','女')),
  5    email    varchar2(20) constraint c_email1 not null
  6                          constraint c_email2 unique,
  7    deptno   number constraint fk refereneces dept(deptno)
  8  );
  deptno   number constraint fk refereneces dept(deptno)
                  *
第 7 行出现错误:
ORA-02253: 此处不允许约束条件说明
SQL> ed
已写入 file afiedt.buf
  1    create table myuser
  2  ( userID number constraint pk primary key,
  3    username varchar2(20) constraint c_name not null,
  4    gender   varchar2(2)  constraint c_gender check (gender in ('男','女')),
  5    email    varchar2(20) constraint c_email1 not null
  6                          constraint c_email2 unique,
  7    deptno   number constraint fk references dept(deptno)
  8* )
SQL> /
表已创建。
SQL> desc myuser;
 名称                                                              是否为空? 类型
 ----------------------------------------------------------------- -------- --------------------------------------------
 USERID                                                            NOT NULL NUMBER
 USERNAME                                                          NOT NULL VARChAR2(20)
 GENDER                                                                     VARChAR2(2)
 EMAIL                                                             NOT NULL VARChAR2(20)
 DEPTNO                                                                     NUMBER
SQL> insert into myuser values(1,'Tom','男','ddd@126.com',10);
已创建 1 行。
SQL> insert into myuser values(1,'Tom','男','ddd@126.com',10);
insert into myuser values(1,'Tom','男','ddd@126.com',10)
*
第 1 行出现错误:
ORA-00001: 违反唯一约束条件 (SCOTT.PK)
SQL> insert into myuser values(2,'Tom','啊','ddd@126.coddm',10);
insert into myuser values(2,'Tom','啊','ddd@126.coddm',10)
*
第 1 行出现错误:
ORA-02290: 违反检查约束条件 (SCOTT.C_GENDER)
SQL> --触发器也可以检查数据的正确与否
SQL> spool off
关于数据库教程相关的教程网站知识今天我们就说到这里了,希望可以帮到大家。

标签:

分享到:

  网友投稿

注册时间:

网站:0 个   APP:0 个  文章:0 篇

  • 76083

    网站

  • 577

    APP

  • 304411

    文章

  • 56004

    会员

赶快注册账号,推广您的网站吧!
文章分类
热门网站
最新入驻APP小程序

宝贝市场2023-02-08

宝贝市场——买手和卖家商品展示

夺宝助手2023-02-08

夺宝助手小程序,查看每日快夺宝平

查诚信2023-02-08

查诚信是一款免费的商业查询工具

车价天天报2023-02-08

快速连接汽车销售,获知汽车最新报

考勤助理小程序2023-02-08

上班签到考勤,实时定位,后台轻松

汽车报价大全查询2023-02-08

汽车报价大全查询提供最新汽车市