oracle方法怎么写,oracle常用方法

myeclipse连接oracle数据库后增删改查方法怎么写,我只写出了查询!

package org.accp.myservlet.entity;

创新新互联,凭借十载的网站设计、成都做网站经验,本着真心·诚心服务的企业理念服务于成都中小企业设计网站有1000+案例。做网站建设,选成都创新互联

import java.sql.*;

public class BaseDao {

//dbUrl数据库连接串信息,其中“1521”为端口,“ora9”为sid

String dbUrl = "jdbc:oracle:thin:@localhost:1521:oracle";

//theUser为数据库用户名

String theUser = "root";

//thePw为数据库密码

String thePw = "root";

//几个数据库变量

Connection c = null;

Statement conn;

ResultSet rs = null;

//初始化连接

public BaseDao() {

try {

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

//与url指定的数据源建立连接

c = DriverManager.getConnection(dbUrl, theUser, thePw);

//采用Statement进行查询

conn = c.createStatement();

} catch (Exception e) {

e.printStackTrace();

}

}

//执行查询

public ResultSet executeQuery(String sql) throws SQLException {

rs = null;

try {

rs = conn.executeQuery(sql);

} catch (Exception e) {

e.printStackTrace();

} finally{

close();

}

return rs;

}

//执行修改

public void update(String sql) throws SQLException{

int len = 0;

try {

len = conn.executeUpdate(sql);

if(len0){

System.out.println("修改成功");

}else{

System.out.println("修改失败");

}

} catch (SQLException e) {

e.printStackTrace();

}finally{

close();

}

}

//执行添加

public void Add(String sql) throws SQLException{

boolean bool = false;

try {

bool = conn.execute(sql);

if(bool){

System.out.println("添加成功");

}else{

System.out.println("添加失败");

}

} catch (SQLException e) {

e.printStackTrace();

}finally{

close();

}

}

//执行删除

public void Delet(String sql) throws SQLException{

boolean bool = false;

try {

bool = conn.execute(sql);

if(bool){

System.out.println("删除成功");

}else{

System.out.println("删除失败");

}

} catch (SQLException e) {

e.printStackTrace();

}finally{

close();

}

}

public void close() {

try {

conn.close();

c.close();

} catch (Exception e) {

e.printStackTrace();

}

}

public static void main(String[] args) throws SQLException {

ResultSet newrs;

BaseDao newjdbc = new BaseDao();

newrs = newjdbc.executeQuery("select * from users");

try {

while (newrs.next()) {

System.out.print(newrs.getString("USERID"));

System.out.print(":"+newrs.getString("USERNAME"));

System.out.print(":"+newrs.getString("PASSWB"));

System.out.print(":"+newrs.getString("EMAIL"));

System.out.println(":"+newrs.getString("GRADE"));

}

} catch (Exception e) {

e.printStackTrace();

}

newjdbc.close();

}

}

oracle的方法怎么写

01.CREATE OR REPLACE FUNCTION get_short_name(p_username VARCHAR2) RETURN VARCHAR2 IS

02.v_username VARCHAR2(1000);

03.

04.BEGIN

05.v_username := p_username;

06.

07.IF INSTR(v_username, 'TenGigabitEthernet') 0 THEN

08.v_username := REPLACE(v_username, 'TenGigabitEthernet', 'TGE');

09.END IF;

10.

11.RETURN v_username;

12.

13.EXCEPTION

14.WHEN NO_DATA_FOUND THEN

15.return null;

16.WHEN OTHERS THEN

17.return null;

18.

19.END get_short_name;

java jdbc连接数据库 oracle的代码实现增删改查的方法怎么写

修改和删除,可以使用ResultSet直接修改,切换到编辑状态就可以。。。。。。。

建议直接使用SQL去修改,特别是删除,使用SQL很快捷

oracle的imp使用方法

oracle的imp使用方法具有三种模式(完全、用户、表)

1、完全:

IMP SYSTEM/MANAGER BUFFER=64000 FILE=C:\FULL.DMP FULL=Y

2、用户模式:

IMP SONIC/SONIC    BUFFER=64000 FILE=C:\SONIC.DMP FROMUSER=SONIC TOUSER=SONIC

这样用户SONIC的所有对象被导入到文件中。必须指定FROMUSER、TOUSER参数,这样才能导入数据。

3、表模式:

EXP SONIC/SONIC    BUFFER=64000 FILE=C:\SONIC.DMP OWNER=SONIC TABLES=(SONIC)

这样用户SONIC的表SONIC就被导入。

扩展资料

ORACLE数据库有两类备份方法。第一类为物理备份,该方法实现数据库的完整恢复,但数据库必须运行在归挡模式下(业务数据库在非归挡模式下运行),且需要极大的外部存储设备,例如磁带库。

第二类备份方式为逻辑备份,业务数据库采用此种方式,此方法不需要数据库运行在归挡模式下,不但备份简单,而且可以不需要外部存储设备。

IMP常用选项

1、FROMUSER和TOUSER,使用它们实现将数据从一个SCHEMA中导入到另外一个SCHEMA中。例如:假设做exp时导出的为test的对象,现在想把对象导入用户:imp userid=test1/test1 file=expdat.dmp fromuser=test1 touser=test1

2、IGNORE、GRANTS和INDEXES,其中IGNORE参数将忽略表的存在,继续导入,这个对于需要调整表的存储参数时很有用,可以先根据实际情况用合理的存储参数建好表,然后直接导入数据。

而GRANTS和INDEXES则表示是否导入授权和索引,如果想使用新的存储参数重建索引,或者为了加快到入速度,可以考虑将INDEXES设为N,而GRANTS一般都是Y。例如:impuserid=test1/test1file=expdat.dmpfromuser=test1touser=test1indexes=N

oracle循环存储过程方法怎么写,每条数据不一样

方法1:用游标可以解决呀!给你个例子。

FOR c IN (SELECT DISTINCT wdd.organization_id,

wdd.ship_from_location_id,

wdd.ship_to_location_id,

wdd.customer_id,

wdd.freight_terms_code,

wdd.fob_code,

wdd.source_header_id,

wdd.source_header_type_id

FROM wsh_delivery_details wdd

WHERE wdd.released_status IN ('R', 'B')

AND wdd.inventory_item_id IN

(SELECT DISTINCT mln.inventory_item_id

FROM bs_edi_shipment_ge bes,

mtl_lot_numbers_all_v mln

WHERE mln.lot_number = bes.lot_number

AND bes.header_id = l_header_id)) LOOP

INSERT INTO Document VALUES(c.organization_id,

c.ship_from_location_id,

c.ship_to_location_id,

c.customer_id,

c.freight_terms_code,

c.fob_code,

c.source_header_id,

c.source_header_type_id);

END LOOP;

将游标里面的数据一条一条的插入到你想插入到的表。

方法2:还有一种方法,定义一个表类型的记录,将所有数据插入到这个表类型记录集中,然后再一次性插入到表中。


本文名称:oracle方法怎么写,oracle常用方法
网页URL:http://ybzwz.com/article/dseeojp.html