zoukankan      html  css  js  c++  java
  • Oracle安装基础

    1.具体操作步骤如下: 开始键 --> 进入运行--> 输入 sqlplus 请输入用户名:sys 输入口令:sys as sysdba //注意:在口令这里输入的密码后面必须要跟上 as sysdba 才可以。 SQL> alter user scott account unlock;      用户已更改. SQL> commit;      提交完成. SQL> conn scott/tiger 更改scott口令 新口令:tiger 重新键入新口令:tiger 口令已更改 已连接。 //完成。

    2. //查看全局数据库名称

    SELECT * FROM GLOBAL_NAME;

    3. //oracle建表设置主键自增

    首先创建一张表

    create table member( memberId number primary key, memberMail varchar2(20)not null, memberName varchar2(20) not null, memberPassword varchar2(20) );   然后,你需要一个自定义的sequence

    CREATE SEQUENCE emp_sequence INCREMENT BY 1 -- 每次加几个 START WITH 1 -- 从1开始计数 NOMAXVALUE -- 不设置最大值 NOCYCLE -- 一直累加,不循环 NOCACHE -- 不建缓冲区   你只有了表和序列还不够,还需要一个触发器来执行它!代码如下:

    create trigger mem_trig before insert on member for each row when (new.memberId is null) begin    select emp_sequence.nextval into:new.memberId from dual;    end;  

    这样就可以就可以了,插入数据测试 insert into member(memberMail,memberName,memberPassword) values('123@qq.com','jack','123456');

    4.// Open the connection OracleConnection connection     = new OracleConnection("Server=Ora; User Id=Scott; Password = tiger;"); connection.Open();   // Create a command OracleCommand command = new OracleCommand(); command.Connection = connection;   // Set the CommandType property to execute // stored procedures or functions by this command command.CommandType = System.Data.CommandType.StoredProcedure;   // Set the name of procedure or function to be executed command.CommandText = "get_all_depts_proc";   // The ParameterCheck property should be true to automatically // check the parameters needed for the procedure execution. command.ParameterCheck = true;   // At this moment, the command is ready for execution. // As we have an output cursor parameter, we may use the command to fill a data table. OracleDataTable dt = new OracleDataTable(command, connection); dt.Fill();

    一览众山小
  • 相关阅读:
    在centos7上使用packstack安装openstack
    解决 React-Native: Android project not found. Maybe run react-native android first?
    javascript_11-函数面试题
    javascript_10-函数
    前端面试记录NO.1
    javascript_09-数组
    javascript_08-while 和 do while
    javascript_07-break 和 continue
    javascript_05-操作符
    javascript_06-控制流程
  • 原文地址:https://www.cnblogs.com/ZLGBloge/p/4086838.html
Copyright © 2011-2022 走看看