zoukankan      html  css  js  c++  java
  • oracle中的数据对象

    oracle中的数据对象有表、视图、索引、序列等

    表的相关操作

    1.创建表

    复制代码
    方式一:                                                                     方式二:
    create table person( create table person1 id number(18),                                    as name varchar2(5), select * from person age number(3), sex varchar2(4) );
    复制代码

     2.删除表

    方式一:只会删除表中的内容,不会删除表结构truncate  delete                         方式二:删除表结构
    truncate table person drop table person
    delete from person where id=123

     3.修改表

    alter table
    A.追加列
    alter table person add (address varchar2(20) default 'shanghai')
    
    B.修改列
    alter table person modify (age number(6))
    使用modify可以修改数据类型,长度,默认值
    请注意:对默认值的修改,只对后面的数据才有效
    
    C.删除列
    alter table person drop column age

    二、视图的相关操作

    创建视图                                 删除视图
    create view person drop view person
    as
    select * from emp

    视图的优点:1.控制访问,可以把主表中某些不想让别人看见的数据隐藏

                     2.可以将多张表的数据构成一个视图,简化查询

                     3.对视图的修改操作会反映到基表中

     三、序列

    创建序列                                            删除序列   drop sequence seq_person

    create sequence seq_person
    increment by 1
    start with 1
    nomaxvalue
    nocycle
    nocache

    使用序列实现主键递增

    insert into person values(seq_person.nextval,’ll’);

    nextval表示下一个值

    currval表示当前值

  • 相关阅读:
    Dubbo简介
    Centos之关机和重启命令
    VirtualBox中CentOS7.2 网络配置(固定IP+联网)
    c#Post方法封装处理
    C# 异步方法处理
    将XMLrequest 改写成fetch
    AsyncCallback
    Promise
    FETCH
    HTML DOM Event 对象
  • 原文地址:https://www.cnblogs.com/coderising/p/5767959.html
Copyright © 2011-2022 走看看