使用 Oracle 的工具,或者将 NetBeans IDE 连接到数据库并使用 IDE 的 SQL 编辑器。NetBeans 7.0 目前仅提供 Beta 或开发版本,可以改进到 Oracle 数据库的连接。要了解如何将 NetBeans IDE 连接到 Oracle 数据库以及如何在数据库中创建用户
使用 Oracle 的工具,或者将 NetBeans IDE 连接到数据库并使用 IDE 的 SQL 编辑器。NetBeans 7.0 目前仅提供 Beta 或开发版本,可以改进到 Oracle 数据库的连接。要了解如何将 NetBeans IDE 连接到 Oracle 数据库以及如何在数据库中创建用户
通过使用所选的工具,创建以下用户:
用户名 user
口令 phpuserpw
系统权限 CREATE TABLE
代码如下 | 复制代码 |
CREATE VIEW CREATE SEQUENCE CREATE TRIGGER |
角色 (Oracle Database 10.x) CONNECT
代码如下 | 复制代码 |
RESOURCE |
下面是一组用于创建该用户的示例 SQL 命令。这些命令假定具有 USERS 和 TEMP 表空间。
代码如下 | 复制代码 |
drop user phpuser cascade;<br><br>create user phpuser identified by phpuserpw;<br><br>grant connect, resource to phpuser;<br><br>alter user phpuser default tablespace users temporary tablespace temp account unlock; |
要排列和存储所需的所有数据,您需要使用两个表:
- 一个是 wishers 表,用于存储注册用户的名称和口令
- 另一个是 wishes 表,用于存储心愿说明
wishers 表包含三个字段:
- id - 许愿者的唯一 ID。该字段用作主键
- name
- 口令
wishes 表包含四个字段:
- id - 心愿的唯一 ID。该字段用作主键
- wisher_id - 心愿所属的许愿者的 ID。该字段用作外键
- description
- due_date - 请求心愿时的日期
这些表通过许愿者的 ID 相关联。除了 wishes 表中的 due_date 以外,所有字段都是必需的。
创建 Oracle 数据库架构
- 以创建的用户身份登录到数据库。
如果通过 NetBeans IDE 进行连接,请使用新用户的名字和口令创建一个连接。确保选择的架构具有与用户相同的名称。(请参见“连接到 Oracle 数据库”教程的建立到 Oracle DB 的连接部分。)
- 要创建 wishers 表,请运行以下 SQL 查询:
代码如下 复制代码 create table wishers (<br> id number not null,<br> name varchar2(50) unique not null,<br> password varchar2(50) not null,<br> constraint wishers_pk primary key(id)<br>);
-
代码如下 复制代码 create table wishes (<br> id number not null,<br> wisher_id number not null,<br> description varchar2(255) not null,<br> due_date date,<br> constraint wishes_pk primary key(id),<br> constraint wishes_fk1 foreign key(wisher_id) references wishers(id)<br>);
注意:您可以在此处下载一组 SQL 命令以创建 Oracle 数据库表。
添加序列和以增加 ID 值
在使用 Oracle 数据库时,您必须指定一个序列以增加值。要在表中添加新成员时增加值,请添加一个触发器。
- 要为 wisher 表添加序列,请运行以下 SQL 命令:
代码如下 复制代码 create sequence wishers_id_seq start with 1 increment by 1;
-
代码如下 复制代码 create or replace trigger wishers_insert
before insert on wishers
for each row
begin
wishers_id_seq.nextval into :new.id from dual;
end;
- 为 wishes 表添加一个序列。
代码如下 复制代码 create sequence wishes_id_seq start with 1 increment by 1;
-
代码如下 复制代码 create or replace trigger wishes_insert
before insert on wishes
for each row
begin
select wishes_id_seq.nextval into :new.id from dual;
end;
注意:您可以在此处下载一组 SQL 命令以创建 Oracle 数据库表,包括序列和触发器。
输入测试数据
要测试应用程序,您需要使用数据库中的某些数据。下面的示例说明了如何添加两个许愿者和四个心愿。
- 添加一个名为 Tom 且口令为 tomcat 的许愿者。
代码如下 复制代码 insert into wishers (name, password) values ('Tom','tomcat');
-
代码如下 复制代码 insert into wishers (name, password) values ('Jerry', 'jerrymouse');<br>commit;
-
代码如下 复制代码 insert into wishes (wisher_id, description, due_date) <br> values (1, 'Sausage', to_date('2008-04-01', 'YYYY-MM-DD');<br><br>insert into wishes (wisher_id, description) <br> values (1, 'Icecream');<br><br><br>insert into wishes (wisher_id, description, due_date) values (2, 'Cheese', to_date('2008-05-01', 'YYYY-MM-DD'));<br><br>insert into wishes (wisher_id, description)<br> values (2, 'Candle');<br>commit;

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Linux new version
SublimeText3 Linux latest version