Oracle常用命令的列举

数据库 Oracle
在Oracle常用命令中有很多的命令式,就是这些的相关命令才使Oracle常用命令在实际的操作中变得更加的灵活,下面就是相关内容的描述。

以下的文章主要是介绍Oracle常用命令,其中包括Oracle数据类型,视图,以及实例的相关的介绍,如果你是Oracle常用命令方面的新手,相对Oracle常用命令的相关应用方面有所了解的话,你就可以点击以下的文章。

Oracle数据类型:

 

Create table test1(name char(10),sex char(1));  
Insert into test1 values(‘tomcatt北京’,’f’);  
Create table test2(name nchar(10),sex nchar(1));  
Insert into test2 values(‘tomcatt北京’,’男’);  
  • 1.
  • 2.
  • 3.
  • 4.

 

删除表 drop table 表名;

 

Create table test3(name varchar2(10),sex varchar2(2));  
Insert into test3 values(‘tomcatt北京’,’f’);  
  • 1.
  • 2.

 

插入值过大

 

Insert into test3 values(‘tomcat北京’,’f’);  
Create table test4(name varchar2(10),age number(3),
salary number(8,2));  
Create table test5(name varchar2(10),birth date);   Insert into test5 values(‘Tom’,’28-2月-08’);   Insert into test5 values(‘Allen’,sysdate);   
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

 

DDL:

创建表

 

create table scott.test6(  
eid number(10),  
name varchar2(20),  
hiredate date default sysdate,  
salary number(8,2) default 0  
)  
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

 

插入数据时若没有指定hiredate,salary的话则会取默认值

以下就是Oracle常用命令中Oracle数据字典的相关介绍:

Dba-所有方案包含的对象信息

All-用户可以访问的对象信息

User-用户方案的对象信息

 

Select * from user_tables;  
Select * from all_tables;  
  • 1.
  • 2.

 

约束:

域完整性约束:not null check

实体完整性约束:unique primary key

参照完整性约束:foreign key

视图:

 

Create or replace view v1(eid,name,salary) as select 
empno,ename,sal from emp where 
deptno = 30
  • 1.
  • 2.

 

序列:sequence

 

Create sequence mysequence1 increment by 1 start
 with 1 nomaxvalue nocycle;  
Insert into test values(mysequence1.nextval,’tom’);   Create sequence student_sequence start with 1
 increment by 1;  
Insert into student values
(student_sequence.nextval,’john’);  
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

 

表间数据拷贝:

 

Insert into dept1(id,name) select deptno,
dname from dept; 
  • 1.
  • 2.

实例(创建表 ID字段自增):

 

create table test2(id char(10) primary key not null,
 name char(10));  
create sequence test2_sequence increment by 1 start
 with 1 nomaxvalue nocycle;  
insert into test2 values(test2_sequence.nextval,'john');   insert into test2 values(test2_sequence.nextval,'allen');   insert into test2 values(test2_sequence.nextval,'candy');   insert into test2 values(test2_sequence.nextval,'aaaa');   insert into test2 values(test2_sequence.nextval,'bbbbb');   insert into test2 values(test2_sequence.nextval,'cccccc');   insert into test2 values(test2_sequence.nextval,'ddddd');   insert into test2 values(test2_sequence.nextval,'eeeee');   insert into test2 values(test2_sequence.nextval,'ggggg');   insert into test2 values(test2_sequence.nextval,'jowwwwhn');   insert into test2 values(test2_sequence.nextval,'aaaadd');   insert into test2 values(test2_sequence.nextval,'ggghhh');   insert into test2 values(test2_sequence.nextval,'eeettt');   insert into test2 values(test2_sequence.nextval,'wwwttt');   select * from test2;  
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.

 

查看表结构

EDITDATA 表名;

修改表字段:

Alter table 表名 modify(字段名 类型 约束);

alter table test modify (addd varchar2(10) null);

alter table 表名 add(字段名 类型 约束);

alter table test add(age varchar2(5));

上述的相关内容就是对Oracle常用命令的描述,希望会给你带来一些帮助在此方面。

【编辑推荐】

  1. Oracle数据库中的两个进程
  2. Oracle reports中实现报表的定长
  3. 执行Oracle sql的实际步骤
  4. Oracle透明网关如何修改人力数据库
  5. Oracle透明网关的内容介绍
责任编辑:佚名 来源: 互联网
相关推荐

2010-04-02 17:51:10

Oracle back

2014-07-25 10:55:36

Linux命令

2011-03-16 10:07:00

2010-04-02 17:37:15

Oracle rman

2014-01-02 09:57:56

PostgreSQL命令

2011-01-19 17:00:09

Postfix常用命令

2020-09-28 15:14:31

Linux常用命令实用命令

2022-05-05 08:08:55

Podman命令Linux

2010-04-09 17:25:05

Oracle 10G

2010-03-29 10:16:39

CentOS常用命令

2011-08-15 22:51:34

Oraclerman

2009-12-22 14:47:24

Linux常用命令

2015-07-28 10:21:23

git命令

2010-04-01 18:10:32

CentOS常用命令

2010-05-28 18:28:51

MySQL常用命令

2015-07-22 17:32:22

mysql常用命令

2011-03-15 09:59:57

2010-03-24 17:44:58

CentOS常用命令

2014-08-18 09:49:46

Linux

2010-05-17 15:41:26

点赞
收藏

51CTO技术栈公众号