创建表空间&PL/SQL语法
-- 首先在数据目录创建finance_dev文件夹 -- 创建表空间 CREATE SMALLFILE TABLESPACE finance_dev DATAFILE 'D:\Database\Oracle\oradata\finance_dev\finance_dev.ora' SIZE 10M EXTENT MANAGEMENT LOCAL AUTOALLOCATE; -- 创建用户及登录密码 CREATE USER finance_dev IDENTIFIED BY finance_dev123; -- 授权表空间 GRANT CONNECT TO finance_dev; GRANT RESOURCE TO finance_dev; GRANT DBA TO finance_dev;
使用Sqlplus登录
CREATE TABLE f_order ( id INTEGER NOT NULL PRIMARY KEY, f_order VARCHAR2(30 CHAR) NOT NULL, hy_code VARCHAR2(30 CHAR) NOT NULL, hy_name VARCHAR2(50 CHAR) NOT NULL, status VARCHAR2(30 CHAR) NOT NULL, add_time TIMESTAMP(6) );
DECLARE hyname VARCHAR2(10) := 'world'; fordercode VARCHAR2(10) := 'f03'; BEGIN UPDATE f_order SET hy_name = hyname WHERE f_order_code = fordercode; IF SQL%notfound THEN INSERT INTO f_order VALUES ( f_order_seq.NEXTVAL, 'f03', '180231777', 'hhh', '3', SYSDATE ); END IF; END;