标签:io ar sp for 数据 on art cti 代码
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();
标签:io ar sp for 数据 on art cti 代码
原文地址:http://www.cnblogs.com/ZLGBloge/p/4086838.html