Java oracle 11g express版如何新建数据库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27357493/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 04:13:04  来源:igfitidea点击:

How to create new database in oracle 11g express edition?

javaoracleoracle11g

提问by

I am new to java, i have installed Oracle Database 11g Express Edition, and also sql developer.

我是 Java 新手,我已经安装了 Oracle Database 11g Express Edition,以及 sql developer。

I have referenced this link How to create a new database after initally installing oracle database 11g Express Edition?, but this is some what differences,

我已经参考了这个链接如何在初始安装 oracle 数据库 11g 快捷版后创建新数据库?,但这是一些什么区别,

I want to know, how to create new database and retrieve data and display data using java.

我想知道,如何使用java创建新数据库并检索数据和显示数据。

I want to know, like as php and phpmyadmin. And also i confused with oracle documentation.

我想知道,就像php和phpmyadmin一样。我也对 oracle 文档感到困惑。

Please help me.. Thanks in advance.

请帮助我.. 提前致谢。

采纳答案by mehdi zahrane

Before you create a database, you must create a user who can be connected to that database, to do that :

在创建数据库之前,您必须创建一个可以连接到该数据库的用户,以执行此操作:

connect system/password;

the password that you entered during the installation.

您在安装过程中输入的密码。

create user :

创建用户 :

create user user1 identified by 'password';

and also to give this user some privileges for creating tables,views and so on . .

并且还给这个用户一些创建表、视图等的权限。.

grant dba,resource, connect to user;

after that you must connect to that user by typing this :

之后,您必须通过键入以下内容连接到该用户:

connect user1/password;

Now you can create tables, like this :

现在您可以创建表,如下所示:

create table exemple(
id int primary key,
name varchar2(255)
);

回答by Kristjan Veskim?e

In Java it's quite popular to use some ORM solution like Hibernate, and it's been abstracted away to be independent of implementation (like Hibernate) with JPA.

在 Java 中,使用一些 ORM 解决方案(如 Hibernate)非常流行,并且它已被抽象为独立于 JPA 的实现(如 Hibernate)。

After you have created database you can also use accompanying tools to generate database schema from your domain classes or vice versa.

创建数据库后,您还可以使用附带的工具从域类生成数据库模式,反之亦然。

Edit:

编辑:

You can create database with Oracle GUI tools like SQL Developer, and then in database you can e.g. run schema generation script (I took this from TechOnTheNet:

您可以使用 SQL Developer 之类的 Oracle GUI 工具创建数据库,然后在数据库中您可以运行模式生成脚本(我从TechOnTheNet 获取

CREATE SCHEMA AUTHORIZATION put_your_user_here
     CREATE TABLE products
        ( product_id number(10) not null,
          product_name varchar2(50) not null,
          category varchar2(50),
          CONSTRAINT products_pk PRIMARY KEY (product_id)
         );

Then e.g. try to connect to your db in Java with JDBC or set up and configure some ORM solution (learning curve may be more difficult) and go from there.

然后,例如尝试使用 JDBC 连接到您的 Java 数据库或设置和配置一些 ORM 解决方案(学习曲线可能更困难)并从那里开始。