I'm trying to export an existing Oracle SQL database schema so that I can use it to build up an Apache Derby database.
Whenever I use the "Database Export" functionality of SQL Developer 4.0.1.14, it generates the sql files, but they are in a format that Apache Derby cannot work with.
Does anybody know of any way to export the schema so that that format is compatible with Apache Derby?
Examples:
Apache Derby wants something like this:
CREATE TABLE "SURVEY"."LOAD_BALANCE"
( "LOAD_BALANCE_ID" NUMBER,
"SURVEY_ID" NUMBER,
"ROUTING_SERVICES" VARCHAR(255),
"ALGORITHM" VARCHAR(255),
"WEIGHT" VARCHAR(255),
"STICKINESS" VARCHAR(255),
"HEALTH_MONITOR" VARCHAR(255),
"SSL_USED" VARCHAR(255)
)
But SQL Developer outputs it like this:
CREATE TABLE "SURVEY"."LOAD_BALANCE"
( "LOAD_BALANCE_ID" NUMBER,
"SURVEY_ID" NUMBER,
"ROUTING_SERVICES" VARCHAR2(255 BYTE),
"ALGORITHM" VARCHAR2(255 BYTE),
"WEIGHT" VARCHAR2(255 BYTE),
"STICKINESS" VARCHAR2(255 BYTE),
"HEALTH_MONITOR" VARCHAR2(255 BYTE),
"SSL_USED" VARCHAR2(255 BYTE)
)
You might try DdlUtils: http://db.apache.org/ddlutils/
I know it supports Derby, and the project website says it supports Oracle, so ...
Related
How can i get xml data from a table,
CREATE TABLE PCRD_3DS_SOAP_LOGS
(
SERVICE_NAME VARCHAR2(50 BYTE) NOT NULL,
REQUEST_ID VARCHAR2(50 BYTE) NOT NULL,
ERROR_CODE CHAR(5 BYTE),
REQUEST SYS.XMLTYPE,
RESPONSE SYS.XMLTYPE,
USER_CREATE VARCHAR2(15 BYTE),
DATE_CREATE DATE,
USER_MODIF VARCHAR2(15 BYTE),
DATE_MODIF DATE
)
I get this error when I execute the select query:
select * from PCRD_3DS_SOAP_LOGS
Access violation at address 659A0C4B in module 'OraClient12.Dll'. Read of address 00000008
SELECT * FROM PCRD_3DS_SOAP_LOGS;
Should work, however, if Toad cannot handle the XMLTYPE data type then you can explicitly convert them to a string using XMLTYPE's getStringVal or getClobVal methods:
SELECT service_name,
request_id,
error_code,
p.request.getClobVal() AS request,
p.response.getClobVal() AS response,
user_create,
date_create,
user_modif,
date_modif
FROM PCRD_3DS_SOAP_LOGS p;
(You do need to include the table name or alias before the column name.)
db<>fiddle here
I have created an external table, everything looks good except for one of the date format, it looks like it defaults to MM/DD/YYYY but I want it as YYYYMMDD as it is in the file. The column is DATE_ID. Anyone have any clues?
Thanks!
CREATE TABLE R2SCHD.AAFES_RDF_XTRNL_CAL_HIER
(
DATE_ID DATE,
DATE_DESC DATE,
WEEK_ID VARCHAR2(25 BYTE),
WEEK_DESC DATE,
MNTH_ID VARCHAR2(25 BYTE),
MNTH_DESC VARCHAR2(25 BYTE),
QRTR_ID VARCHAR2(25 BYTE),
QRTR_DESC VARCHAR2(25 BYTE),
HALF_ID VARCHAR2(25 BYTE),
HALF_DESC VARCHAR2(25 BYTE),
YEAR_ID VARCHAR2(25 BYTE),
YEAR_DESC VARCHAR2(25 BYTE),
DOW_ID VARCHAR2(25 BYTE),
DOW_DESC VARCHAR2(25 BYTE)
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY R2SCHD_STATIC_DATA
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
NOBADFILE
NOLOGFILE
NODISCARDFILE
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
(
DATE_ID CHAR(8) DATE_FORMAT DATE MASK "YYYYMMDD",
DATE_DESC CHAR(10) DATE_FORMAT DATE MASK "MM/DD/YYYY",
WEEK_ID,
WEEK_DESC CHAR(10) DATE_FORMAT DATE MASK "MM/DD/YYYY",
MNTH_ID, MNTH_DESC, QRTR_ID, QRTR_DESC, HALF_ID,
HALF_DESC, YEAR_ID, YEAR_DESC, DOW_ID, DOW_DESC
)
)
LOCATION (R2SCHD_STATIC_DATA:'rdft_cal_external.dat')
)
REJECT LIMIT UNLIMITED
NOPARALLEL
NOMONITORING;
You created the date_id as DATE data type, which is correct. Dates do not have a "format" - what you see on your screen, with slashes, is dictated by your NLS_DATE_FORMAT setting. What are you using - SQL*Plus? SQL Developer? Toad?
For example in SQL Developer: Tools - Preferences - Database - NLS and you will see (and be able to change) your date format. That is what controls what is shown on your screen - not the format you used for your external table (it won't help you to set it as 'YYYYMMDD' there).
I see every day a lot of DDL statemente where i work, and i have seen that the people use to us,.Binary Multiples , but when i ask why, nobody tell me a real reason.
i mean
Create Table User(
User_name Varchar2(64 Byte),
User_comment (256 Byte),
User_Description (1024 Byte)
)
I see so often these values and i dont know why , if there is a logic behind that.
I am creating multiple tables in MS SQL SERVER 2014 to that will receive data from an Oracle server. Some of the data types that are coming over from Oracle are set to VARCHAR2 (15 BYTE), VARCHAR2(60 BYTE) ETC....
I need to know what I should set my data types too in the MS SQL SERVER tables.
ITEM_NO VARCHAR(15 BYTE)
UNIT_OF_MEASURE CHAR(2 BYTE)
PARTNER_SKU VARCHAR(15 BYTE)
UPC CHAR(12 BYTE)
ITEM_DESC VARCHAR(60 BYTE)
ALT_ITEM_NO VARCHAR(15 BYTE)
As previously stated in the comments above by #Gordon Linoff and #user2067753 in SQL Server you do not need to define the word BYTE when specifying data types in SQL Server. So for your declared fields above:
ITEM_NO VARCHAR(15)
UNIT_OF_MEASURE CHAR(2)
PARTNER_SKU VARCHAR(15)
UPC CHAR(12)
ITEM_DESC VARCHAR(60)
ALT_ITEM_NO VARCHAR(15)
MSDN has many articles which you might also find helpful:
Data Types
Creating Tables
You also might find these documents quite useful as it compares both Microsoft SQL Server to Oracle and documents a load of the differences:
From Oracle
On MSDN
Byte in Oracle is optional, Just used to enforce the size to be specific number of bytes rather than the length of the varchar value. There is no equivalent in SQL Server
i have this table
CREATE TABLE WishList(
idWishList VARCHAR2(40 BYTE) ,
WishListName VARCHAR2(40 CHAR) NOT NULL,
id_User VARCHAR2(40 BYTE) NOT NULL
)
now how can i use auto_increment with varchar in oracle ??
You can add a trigger:
create or replace trigger some_trig_name
before insert on WishList
for each row
begin
:new.idWishList := to_char(your_sequence.nextval);
end some_trig_name;
In the example I used a seq but you can put whatever you want
As I remember, Oracle doesn't have an auto_increment functionality. It has sequences and developers should add special function like getNextId() and use it in insert statements like
insert into table (id,...) values(getNextId() ,..)
So, you can implement you own function which returns new id for your field with your own algorithm.