alter user phpuser default tablespace users temporary tablespace temp account unlock;
设计样例数据库的结构
要排列和存储所有必需数据,您需要使用两个表:
一个是 wishers 表,用于存储注册用户的名称和口令
一个是 wishes 表,用于存储心愿说明
wishers 表包含三个字段:
id - 许愿者的唯一 ID。该字段用作主键
name
password
wishes 表包含四个字段:
id - 心愿的唯一 ID。该字段用作主键
wisher_id - 心愿所属的许愿者的 ID。该字段用作外键。
description
due_date - 请求心愿时的日期
这些表通过许愿者的 ID 相关联。除了 wishes 表中的 due_date 以外,所有字段都是必填的。
创建 Oracle 数据库架构
以创建的用户身份登录到数据库。
如果通过 NetBeans IDE 进行连接,请使用新用户的名字和口令创建一个连接。确保选择的架构具有与用户相同的名称。(请参见“连接到 Oracle 数据库”教程的建立到 Oracle DB 的连接部分。)
要创建 wishers 表,请运行以下 SQL 查询:
create table wishers ( id number not null, name varchar2(50) unique not null, password varchar2(50) not null, constraint wishers_pk primary key(id) );
要创建 wishes 表,请运行以下 SQL 查询。请注意,将创建一个外键,使心愿与许愿者相关联。
create table wishes ( id number not null, wisher_id number not null, description varchar2(255) not null, due_date date, constraint wishes_pk primary key(id), constraint wishes_fk1 foreign key(wisher_id) references wishers(id) );