• Oracle数据库基础操作


    1.oracle数据库创建用户zhangsan

     create user zhangsan  

    2.oracle数据库设置密码zhangsan

     Identified by zhangsan

    3.oracle数据库给用户授予权限

     grant connect,resource to zhangsan 


    4.创建序列

     创建序列表(sequence)可以用连续的整数为表中的列自动生成值,1个序列可以为多表生成序列值

     create sequence seq start with 1 increment by 1

     查看建好的序列

    select seq.nextval from dual;

    select seq.currval from dual; 

    6.变量赋值

    declare//声明

    :=//赋值 

    DECLARE tableAnt BUMBER:=0; 


    8.按条件查询表格数目,Oracle数据库条件表达式使用

    /*Oracle中,满足一定条件下,想运行多条语句,就用begin,end*/ 

    DECLARE tableAnt BUMBER:=0; 

     begin 

    -- 查询结果赋值给tableAnt变量 

    select count(*) into tableAnt from USER_TABLES where TABLE_NAME='USERS';

     --  打印tableAnt变量值

    dbms_output.put_line('满足条件表数目'||tableAnt); 

    if(tableAnt>0) then

                     begin 

    drop table USERS;

    end; 

    end if 

    execute immediate 

    ||'create table USERS('

      ||'id number(11,0) primary key,'

      ||'uname varchar2(30) not null,'

      ||'upass varchar2(20) not null,'

      ||'ubirth date default(sysdate) not null '

    ||')';

             end ;

    9.Oracle创建表格、删除表格、修改表格、查询表格

    查看系统视图 (区分大小子写),是否存在该用户

    select count(*) from USER_TABLES where Table_name='USERS' 

    建表

    create table USERS(

      id number(11,0) primary key,

      uname varchar2(30) not null,

      upass varchar2(20) not null,

      ubirth date default(sysdate) not null 

    ); 

     查询

    select * from users;

    删除表 

    drop table users; 

    删除数据 

    delete from USERS where ID=2; 

    插入记录

    insert into USERS values(1,'Apache','123',sysdate); 

    指定日期 

    insert into USERS values(1,'Apache','123',to_date('1995-12-10 11:11:11','yyyy-mm-dd hh:mm:ss')); 

    修改 

    update USERS 

    SET UPASS='222222' where ID>5 AND to_number(to_char(ubirth,'yyyy'))>2015; 

    10.表格分页技术:核心(查出第n条记录,删除n-1条记录),结果是第n条记录

    11.Oracle储存过程

                  欲看详细解析,请听下回分解

  • 相关阅读:
    android 项目
    input keyevent 数字对应的操作
    logcat 使用方法
    android查看内存使用情况
    图片点击放大效果
    禁止img图片拖动在新窗口打开
    人工智能
    游戏开发
    随手做的一个模拟弹出窗口
    Html的<meta>标签使用方法及用例
  • 原文地址:https://www.cnblogs.com/2070393244com/p/9446525.html
Copyright © 2020-2023  润新知