CREATE SEQUENCE mylobs_id_seq
NOMINVALUE
NOMAXVALUE
NOCYCLE
CACHE 20
NOORDER
INCREMENT BY 1;
CREATE TABLE mylobs (
id NUMBER PRIMARY KEY,
mylob CLOB
)
插入
<?php header("content-type:text/html;charset=utf-8"); error_reporting(E_ALL); set_time_limit(0); echo "<pre>"; $conn=oci_connect(‘demo‘,‘demo‘,‘localhost/xe‘,‘utf8‘); $sql = "INSERT INTO $stmt = oci_parse($conn, $sql); $myLOB = oci_new_descriptor($conn, OCI_D_LOB); oci_bind_by_name($stmt, ":mylob_loc", $myLOB, -1, OCI_B_CLOB); oci_execute($stmt, OCI_DEFAULT) or die ("Unable to execute query\n"); $content=str_repeat(‘你‘,80000); |
查询
<?php header("content-type:text/html;charset=utf-8"); error_reporting(E_ALL); set_time_limit(0); echo "<pre>"; $conn=oci_connect(‘demo‘,‘demo‘,‘localhost/xe‘,‘utf8‘); $sql = "SELECT * FROM mylobs ORDER BY id"; $stmt = oci_parse($conn, $sql); oci_execute($stmt) or die ("Unable to execute query\n"); while ( $row = oci_fetch_assoc($stmt) ) { oci_close($conn); |
修改
<?php header("content-type:text/html;charset=utf-8"); error_reporting(E_ALL); set_time_limit(0); echo "<pre>"; $conn=oci_connect(‘demo‘,‘demo‘,‘localhost/xe‘,‘utf8‘); $sql = "SELECT mylob FROM mylobs WHERE id = 1 FOR UPDATE"; $stmt = oci_parse($conn, $sql); oci_execute($stmt, OCI_DEFAULT) or die ("Unable to execute query\n"); if ( FALSE === ($row = oci_fetch_assoc($stmt) ) ) { if ( !$row[‘MYLOB‘]->truncate() ) { if ( !$row[‘MYLOB‘]->save(‘UPDATE: ‘.date(‘H:i:s‘,time()) ) ) { oci_free_statement($stmt); oci_close($conn); |