Oracle 12 c: create table
On oracle 12 c, with sqlplus
[CODE]
SQL > CREATE TABLE "minimum")
2 'iddurata' NUMBER (11) NOT NULL,
3 "minimum" NVARCHAR2 (40) NOT NULL
4 )
5;
Table created.
[/ CODE]
[CODE]
INSERT INTO 'minimum' VALUES ('1' 1:30 ');
1 line of creation.
[/ CODE]
[CODE]
SQL > select * from minimum;
Select * from minimum
*
ERROR on line 1:
ORA-00942: table or view does not exist
[/ CODE]
Why?
by default, the names of the objects are uppercase. When you created your table you forced the name to be lowercase by placing the name between quotes. But when you tried to choose in this one, you have left the name unlisted, then oracle tried to find a table named 'MINIMUM '. "MINIMUM"! = 'minimum '.
Bottom line is that you must never create objects with quotation marks around their names, thus leaving oracle create them with the default value of the uppercase names.
And before you start - no, you don't want them to be lower - or uppercase-lowercase. It causes simply indescribable sadness that begin you already to experience.
You can get your results with ' SELECT * FROM 'minimum' ', but you really want to go.
Tags: Database
Similar Questions
-
DROP TABLE TWO.
DROP TABLE ONE;
CREATE TABLE 'A
(
ACTIVATE THE 'ID' NUMBER NOT NULL,
ACTIVATE THE "SERIAL" VARCHAR2 (10 BYTE) NOT NULL,
ACTIVATE THE "FIRST NAME" VARCHAR2 (30 BYTE) NOT NULL,
ENABLE 'PK_ONE' CONSTRAINT PRIMARY KEY ('ID', "SERIAL")
)
TABLESPACE 'USERS ';
CREATE TABLE "TWO"
(
ACTIVATE THE 'ID' NUMBER NOT NULL,
ACTIVATE THE "SERIAL" VARCHAR2 (5 BYTE) NOT NULL,
ACTIVATE THE "DEGREE_CODE" VARCHAR2 (10 BYTE) NOT NULL,
'TEST_NAME' VARCHAR2 (20 BYTE),
ACTIVATE THE KEY PRIMARY CONSTRAINT 'PK_TWO' ('ID', 'SERIAL'),
"FK_TWO' FOREIGN KEY ('ID', 'DEGREE_CODE') CONSTRAINT REFERS TO 'ONE' ('ID', 'SERIAL') MAYBE DEFERRED ENABLE
)
TABLESPACE 'USERS ';
If we use the above sql scripts to create the tables and create the ADF BC using the above 2 tables, all 4 columns in table 2 are reported as the primary key.
User, tell us your version of Jdev, please!
You should file an SR with support.oracle.com for this.
As a work around you can change the area of occurrence, and remove the check mark key pirmary on the unwanted columns. After that, it should work.
Timo
-
Oracle 11g R2, CREATE THE TABLE and QUOTAS
Hi all
I need some insight on a strange behavior, that I discovered in Oracle 11 g 2. Don't know if I'm missing something or if I just discovered a security issue with Oracle.
Oracle Version: 11.2.0.1.0
The problem is with the CREATE TABLE and the QUOTA on the specific tablespace privilege.
Please, try this on your system (if you have some free time and care to confirm the "bug").
Create a user, grant privileges than two, CREATE THE SESSION and CREATE TABLE.
Grant NO quota on any tablespace.
Try to create a table on any tablespace (except SYSTEM) and everybody say if it worked or not.
The oracle documentation provides the following:
To create a relational table in your own schema, you must have the CREATE TABLE system privilege. To create a table in the schema of another user, you must have the CREATE ANY TABLE system privilege. In addition, the owner of the schema containing the table must have a quota of space on the tablespace contains the table or the UNLIMITED TABLESPACE system privilege.
[http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_7002.htm#SQLRF01402]
The fact is, so far, on two different instances of Oracle 11 g 2, my users are not limited in the creation of the tables only when they have quotas, but where they want to, except the STRING.
The behavior correct would be to deny the creation of the table the tablespace where there is no quota, but it does not work.
My instance of Oracle 10 g behave properly and therefore the creation of the table is denied the tablespace with no quota.
P.s1 sorry if this a well known "bug/problem/question". I've been ridiculous on a well-known forum for the same question. I don't need to be "filled spoon" as shown on this famous site! I have read the documentation! I googled a lot!
P.s2 even if the creative work of table on tablespace with no quota, you cannot insert data into it. Yes, big picture, the user cannot not filled space with irrelevant data tables, but it can create thousands of tables...!
Did I miss something?
Is there a 'default' option I have to mark to prevent the creation of the table where it shouldn't?
? (?)Please read http://tkyte.blogspot.com/2011/02/deferred-segment-creation.html.
-
Problem with Create Table from target in CKM Oracle
In CKM following Oracle are:
create table < % = snpRef.getTable ("L", "CHECK_NAME", "W") % >
(
Catalog_name < %=snpRef.getDataType ("DEST_VARCHAR", "100", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
Schema_name < %=snpRef.getDataType ("DEST_VARCHAR", "100", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
RESOURCE_NAME < %=snpRef.getDataType ("DEST_VARCHAR", "100", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
FULL_RES_NAME < %=snpRef.getDataType ("DEST_VARCHAR", "100", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
ERR_TYPE < %=snpRef.getDataType ("DEST_VARCHAR", "1", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
ERR_MESS < %=snpRef.getDataType ("DEST_VARCHAR", "250", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
CHECK_DATE < %=snpRef.getDataType ("DEST_DATE", "", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
ORIGINAL < %=snpRef.getDataType ("DEST_VARCHAR", "100", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
CONS_NAME < %=snpRef.getDataType ("DEST_VARCHAR", "35", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
CONS_TYPE < %=snpRef.getDataType ("DEST_VARCHAR", "2", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >.
ERR_COUNT < %=snpRef.getDataType ("DEST_NUMERIC", "10", "") % > < % = snpRef.getInfo ("DEST_DDL_NULL") % >
)
What is product is...
create the table ETL_STAGING. SNP_CHECK_TAB
(
CATALOG_NAME VARCHAR2 (100 CHAR) NULL,
SCHEMA_NAME VARCHAR2 (100 CHAR) NULL,
RESOURCE_NAME VARCHAR2 (100 CHAR) NULL,
FULL_RES_NAME VARCHAR2 (100 CHAR) NULL,
ERR_TYPE VARCHAR2 (1 CAR) NULL,
ERR_MESS VARCHAR2 (250 CHAR) NULL,
CHECK_DATE DATE NULL,.
ORIGINAL VARCHAR2 (100 CHAR) NULL,
CONS_NAME VARCHAR2 (35 CHAR) NULL,
CONS_TYPE VARCHAR2 (2 CHAR) NULL,
ERR_COUNT NUMBER (10) NULL
)
Why it adds the word TANK in parenthesis? Anyone?
Tom CusickHello
Follow these steps:
(1) go to the topology
(2) physical architecture
(3) modify the Oracle (directory) technology
4) go to the tab "other".
(5) change the "String Mask" (4º-text box) to: VARCHAR2 (%)
That will solve the problem.
Cezar Santos
-
FREELISTS and FREELIST GROUPS of CREATE TABLE
My oracle 10g, create table statement is below:
CREATE TABLE S005. Test
(
AAA char (1)
)
PCTFREE 0
STORAGE)
FREELISTS 10
FREELIST GROUPS 20
)
LOGGING
NOCACHE
NOPARALLEL
NOMONITORING;
After performing this sql, I have a query table USER_TABLES but FREELISTS and FREELIST_GROUPS fields show nothing.
In my view, FREELISTS value must be 10, and FREELIST_GROUPS should be 20. How to retrieve these values?
Thank you very much
-
How to force the data type in create table field?
Hi all
I need to force my table to create as follows
Create table XYZ
(Test varchar2 (10 CHAR)
...
);
When I run my Interface the script is
Create table XYZ
(Test varchar2 (10))
...
);
and the DBMS translated into
Create table XYZ
(Test varchar2 (10 BYTE),
...
);
I have the same problem with I$, C$, and so on.
Best regards
Marco
Hi all
I fix my problem:
In Phisical Tecnology, under ORACLE Tecnology, data TYPE, I modified the definition of VARCHAR2 in VARCHAR2(%L CHAR).
(Before it was VARCHAR2 (%)).
Thank you all.
Marco
-
Need help - multilevel nested table - create table problem
Hello
My version of oracle db: 11g
I just created a table that contains a nested multi-level table.
Here is the code:
create or replace type sdef_t_nt_empNames21 is table of the varchar2 (50);
create or replace type sdef_ot_SCmarks21 as an object (number of physics, chemistry number, number of Biology);
create or replace type sdef_t_nt_SCmarks21 is table of the sdef_ot_SCmarks21;
create or replace type sdef_ot_allsubmarks21 as an object (eid, eng, math, sc sdef_t_nt_SCmarks21 number number);
create or replace type sdef_t_nt_dep_m_info21 is table of the sdef_ot_allsubmarks21;
create the table nt_dep21
(number of fact
, dname varchar2 (50)
c_sdef_t_nt_empNames21 sdef_t_nt_empNames21
c_sdef_t_nt_dep_m_info21 sdef_t_nt_dep_m_info21)
nested as NT_c_sdef_t_nt_empNames21 table c_sdef_t_nt_empNames21 store
store table nested like NT_c_sdef_t_nt_dep_m_info21; c_sdef_t_nt_dep_m_info21 <-I know that the problem is here.
TRACE OF THE ERROR:
Error at startup on line: 13 in the command.
create the table nt_dep21
(number of fact
, dname varchar2 (50)
c_sdef_t_nt_empNames21 sdef_t_nt_empNames21
c_sdef_t_nt_dep_m_info21 sdef_t_nt_dep_m_info21)
nested as NT_c_sdef_t_nt_empNames21 table c_sdef_t_nt_empNames21 store
Nested table c_sdef_t_nt_dep_m_info21 (sdef_t_nt_SCmarks21) store as NT_c_sdef_t_nt_dep_m_info21
Error report-
SQL error: ORA-00904: invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
PS: I'm just solve a problem given to me by some1, is not a practical implementation, I'm just trying to get through
I'm sure that some1 could help me with this, I have searched a lot of this problem but could not find my answer, please help me.
Concerning
Rahul
SQL > create table (nt_dep21)
Did number 2,
3 dname varchar2 (50).
4 c_sdef_t_nt_empNames21 sdef_t_nt_empNames21,
c_sdef_t_nt_dep_m_info21 5 sdef_t_nt_dep_m_info21
6 )
store c_sdef_t_nt_empNames21 7 nested as NT_c_sdef_t_nt_empNames21 table
store c_sdef_t_nt_dep_m_info21 8 table nested as NT_c_sdef_t_nt_dep_m_info21)
9 table nested as NT_sc sc store
10 )
11.Table created.
SQL >
SY.
-
Hi all
11.2.0.3.10
AIX6
I created a user SCOTT in our database.
I have grant connect, resource to scott; because it is easier to do it this way.
DBA, I wish that I'm the only one to create all the tables of scott, and he cannot create for himself.
What is the effective way to do this? Is this order enough? > REVOKE CREATE a TABLE FROM SCOTT;
Thank you
MK
RP gave you the right answer if you want to restrict users to create table, do not give them privilege resource. See this demo:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With partitioning, OLAP, Data Mining and Real Application Testing options
SQL > create user test identified by the test.
Created by the user.
SQL > grant connect to test;
Grant succeeded.
SQL > connect test/test;
Connected.
SQL > create table tab1 (a number);
create table tab1 (a number)
*
ERROR on line 1:
ORA-01031: insufficient privileges
SQL > connect sys/pw as sysdba
Connected.
SQL > grant create table to test;
Grant succeeded.
SQL > connect test/test;
Connected.
SQL > create table tab1 (a number);
Table created.
SQL > connect sys/pw as sysdba
Connected.
SQL > revoke create table test;
Revoke succeeded.
SQL > connect test/test;
Connected.
SQL > create table tab2 (a number);
create the table tab2 (a number)
*
ERROR on line 1:
ORA-01031: insufficient privileges
SQL >
Concerning
Girish Sharma
-
using datediff, creating table
Hi all
I'm trying to calculate the number of years of a product when a new record is inserted.
That's what I tried
CREATE TABLE WaterMeter)
meterID VARCHAR (25) NOT NULL,
readingID VARCHAR (25) NOT NULL,
meterSerialNum VARCHAR (25) NOT NULL,
installationDate DATE NOT NULL,
noOfYears AS (DATEDIFF (YEAR, sysdate, installationDate));
CONSTRAINT watermeter_Pkey PRIMARY KEY (meterID).
Watermeter_Altkey of UNIQUE CONSTRAINT (meterSerialNum)
);
and the following error appeared.
Error in the command line column: 6:27
Error report:
SQL error: ORA-00904: "YEAR": invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
so, how can I go around to solve this issue?
Virtual column is... virtual. It is not stored in the table. Oracle calculates the value of virtual column every time that reference you it. This is why you cannot use functions such as SYSDATE in a virtual column expression. I understand the logic underlying your table, but this is done using views. Simply create the table without column of noOfYears, then
create or replace view WaterMeter_VW as select t.*, MONTHS_BETWEEN (sysdate, installationDate) / 12 WaterMeter noOfYears t;
SY.
-
Hello
I create 2 APEX table with foreign key; the first table is OK, but in the second table, I get an error "ora-00905 keyword missing."
This is the statement:
"
-- -----------------------------------------------------
-Table "PATRIMONIO." 'SCHEDA_ANAGRAFICA '.
-- -----------------------------------------------------
CREATE TABLE SCHEDA_ANAGRAFICA (
ID_SCHEDA VARCHAR (20) NOT NULL ,
MUNICIPIO VARCHAR (45) NULL ,
ADDRESS VARCHAR (45) NULL ,
DIP_CONSEGANTARIO VARCHAR()45() NULL
DETAILS VARCHAR (45) NULL ,
TIPOLOGIA VARCHAR (45) NULL ,
DESCR_IMMOBILE VARCHAR()90) NULL
PRIMARY KEY (ID_SCHEDA) );
-- -----------------------------------------------------
-Table "PATRIMONIO." 'SCHEDA_AMMINISTRATIVA '.
-- -----------------------------------------------------
CREATE TABLE SCHEDA_AMMINISTRATIVA (
ID_SCHEDA VARCHAR (20) NOT NULL ,
DESCR_TRASFERIMENTO VARCHAR()45() NOT NULL
NOTA_TRASCRIZIONE VARCHAR()45() NULL
ASSEGNAZIONE VARCHAR (45) NULL ,
VERB_CONSEGNA VARCHAR (45) NULL ,
CONCESSIONE VARCHAR (45) NULL ,
NOTE VARCHAR (45) NULL ,
PRIMARY KEY ( )ID_SCHEDA DESCR_TRASFERIMENTO)
Fk_AMMINISTRATIVA_ANAGRAFICA of the CONSTRAINT
FOREIGN KEY (ID_SCHEDA)
REFERENCES SCHEDA_ANAGRAFICA ()ID_SCHEDA( )
WE REMOVE ANY ACTION
ON UPDATE NO ACTION );
"
I don't understand the cause.
Can you help me?
Thank you
5fd006d0-5573-4a0f-821a-63f2bd8083fd wrote:
Please update your forum profile with a real handle instead of '5fd006d0-5573-4a0f-821a-63f2bd8083fd '.
I create 2 APEX table with foreign key; the first table is OK, but in the second table, I get an error "ora-00905 keyword missing."
You create tables in the Oracle RDBMS, not by their SUMMIT. APEX is a development tool, not a database.
This is the statement:
"
-- -----------------------------------------------------
-Table "PATRIMONIO." 'SCHEDA_ANAGRAFICA '.
-- -----------------------------------------------------
CREATE TABLE SCHEDA_ANAGRAFICA)
ID_SCHEDA VARCHAR (20) NOT NULL,
NULL IN MUNICIPIO OF VARCHAR (45).
ADDRESS VARCHAR (45) NULL,
DIP_CONSEGANTARIO VARCHAR (45) NULL,
DETAILS VARCHAR (45) NULL,
TIPOLOGIA VARCHAR (45) NULL,
DESCR_IMMOBILE VARCHAR (90) NULL,
PRIMARY KEY (ID_SCHEDA));
-- -----------------------------------------------------
-Table "PATRIMONIO." 'SCHEDA_AMMINISTRATIVA '.
-- -----------------------------------------------------
CREATE TABLE SCHEDA_AMMINISTRATIVA)
ID_SCHEDA VARCHAR (20) NOT NULL,
DESCR_TRASFERIMENTO VARCHAR (45) NOT NULL,
NOTA_TRASCRIZIONE VARCHAR (45) NULL,
ASSEGNAZIONE VARCHAR (45) NULL,
VERB_CONSEGNA VARCHAR (45) NULL,
CONCESSIONE VARCHAR (45) NULL,
NOTE VARCHAR (45) NULL,
PRIMARY KEY (ID_SCHEDA, DESCR_TRASFERIMENTO).
CONSTRAINT fk_AMMINISTRATIVA_ANAGRAFICA
FOREIGN KEY (ID_SCHEDA)
REFERENCES SCHEDA_ANAGRAFICA (ID_SCHEDA)
ON DELETE NO ACTION
UPDATE NO ACTION);
"
I don't understand the cause.
Ni NO ACTION or ON UPDATE are valid in a REFERENCES clause in Oracle. If you want to default to make referential integrity checks can remove these clauses. The only other options are ON DELETE CASCADE/SET NULL.
-
Create table based on the timestamp prtition generate ORA-14752
Hello
I have following question - why create table 1 generate ORA-14752 script? Script 2 works without any problem. Feel it is on interval - day/month. How to create the script table 1?
Database:
Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
1.
create table
(pData
start_date TIMESTAMP,
store_id NUMBER,
inventory_id NUMBER (6)
)
PARTITION OF RANGE (start_date)
INTERVAL (NUMTOYMINTERVAL (1, 'DAY'))
(
PARTITION pdata_p2 VALUES LESS THAN (TO_DATE (' 07/01/2007 ',' DD-MM-YYYY ""));
PARTITION pdata_p3 VALUES LESS THAN (TO_DATE (' 08/01/2007 ',' DD-MM-YYYY ""))
);
2.
create table
(pData
start_date TIMESTAMP,
store_id NUMBER,
inventory_id NUMBER (6)
)
PARTITION OF RANGE (start_date)
INTERVAL (NUMTOYMINTERVAL (1, 'MONTH'))
(
PARTITION pdata_p2 VALUES LESS THAN (TO_DATE (' 07/01/2007 ',' DD-MM-YYYY ""));
PARTITION pdata_p3 VALUES LESS THAN (TO_DATE (' 08/01/2007 ',' DD-MM-YYYY ""))
);
YM in NUMTOYMINTERVAL stands for the year and the month. With NUMTODSINTERVAL it should work.
create table
(pData
start_date TIMESTAMP,
store_id NUMBER,
inventory_id NUMBER (6)
)
PARTITION OF RANGE (start_date)
INTERVAL (NUMTODSINTERVAL (1, 'DAY'))
(
PARTITION pdata_p2 VALUES LESS THAN (TO_DATE (' 07/01/2007 ',' DD-MM-YYYY ""));
PARTITION pdata_p3 VALUES LESS THAN (TO_DATE (' 08/01/2007 ',' DD-MM-YYYY ""))
);
-
Hello
I am a fairly new user for Oracle and have found this place to be very useful as I'm learning! One of the guidelines is to provide sample CREATE TABLE and INSERT data. I read the FAQ and in other forums to see if I could better understand this process, but I'm still struggeling reflected. Please can someone explain exactly what I do for these data, I want to be sure that I provided as useful information a lot in my posts to get help as soon as possible. I appreciate everything / all the answers!
Hello
Daniel Strong wrote:
So, something like this:
INSERT INTO skills (mu_id, external_id, skill_nm, skill_level) VALUES(220,AB,FAST,1);
INSERT INTO skills (mu_id, external_id, skill_nm, skill_level) VALUES(7,BB,SLOW,7);
INSERT INTO skills (mu_id, external_id, skill_nm, skill_level) VALUES(221,BC,FAST,1);
INSERT INTO skills (mu_id, external_id, skill_nm, skill_level) VALUES(8,BD,SLOW,2);
INSERT INTO skills (user_id, skill_nm) VALUES (AB, SLOW);
INSERT INTO skills (user_id, skill_nm) VALUES (BB, SLOW);
INSERT INTO skills (user_id, skill_nm) VALUES (BC, DOWN);
INSERT INTO skills (user_id, skill_nm) VALUES (BD, SLOW);
DESIRED RESULTS:
MU_ID EXTERNAL_ID SKILL_NAME SKILL_LEVEL
220 AB FAST 1
221 AV FAST 1When you get a response, you want it works or is it OK if the answer causes errors?
Obviously, you want people to post answers that work. Make sure that the code of that validation works, too. Test (and, if necessary, correct) your INSERT statements in your own development before posting on this forum system.The literal string values must be in single quotes. I think you meant:
INSERT INTO skills (external_id, skill_nm, mu_id, skill_level) VALUES (220, "AB", "QUICK", 1);
Without the single quotes, AB and FAST are considered as column names or function.
-
CREATE TABLE... COMPRESS
Hello
I'm trying the COMPRESSION with CREATE TABLE option. I wanted to just understand if we need the "Advanced Compression" option turned on.
That requires an additional license?
Kind regards
Vikram
Compression of the base table is available without an additional license for Oracle Enterprise Edition.
-
Create table with overlapping parallel dates in individual columns
I try to combine data from two different tables into a single table.
The data in table 1 contains locations of patients in a hospital where each record represents a single location. Patients can be transferred several times between the different beds resulting from multiple records for a single visit.
The data in table 2 contains the operative activity of the patient to the Hospital where each record represents either the GOLD of the suspension of the recovery room. A patient may have multiple operations in a single visit.
I would like to join/merge/mashup data in a single table that contains the data parallel to each other. In other words, dates of the appliance on one side of the table and the activity of GOLD on the other. The difficulty is that the two sets of overlapping of dates of arrival and departure. I wish that the final table to divide the originals in new records when the overlaps do not coincide.
Example:
Original in both events (one per table)
> Unit event has - from 14:00 to 18:00
> OR event B - from 16:00 to 17:00
Results in 3 documents (in the final)
> Event 1 - unit from 14:00 to 16:00, null dates GOLD
> Event 2 - unit from 16:00 to 17:00 OR 16:00 to 17:00
> Event 3 - unit from 17:00 to 18:00, null dates GOLD
Of course overlap can be more complex than the example above and adding code to indicate the 'ghosts' transfers to as well.
In the code below, the first visit of the GOLD occurs during the first mention of the unit.
Jason
Oracle 10g
[code]
create the table delme_Unit_dates
(id varchar2 (20))
, unit_rcd_id varchar2 (20)
, Unit_desc varchar2 (20)
Unit_in_code char (1)
Date of Unit_in_dttm
Date of Unit_out_dttm
Unit_out_code char(1));
create the table delme_or_dates
(id varchar2 (20))
, OR_rcd_id varchar2 (20)
, OR_desc varchar2 (20)
OR_in_code char (1)
Date of OR_in_dttm
Date of OR_out_dttm
OR_out_code char(1));
create the table delme_all_dates
(id varchar2 (20))
, Unit_OR_id varchar2 (40)
, Unit_rcd_id varchar2 (20)
, Unit_desc varchar2 (20)
Unit_in_code char (1)
Date of Unit_in_dttm
Date of Unit_out_dttm
Unit_out_code char (1)
, OR_rcd_id varchar2 (20)
, OR_Desc varchar2 (20)
OR_in_code char (1)
Date of OR_in_dttm
Date of OR_out_dttm
OR_out_code char (1));
insert into delme_unit_dates values ('123456', 'U1111', 'Unit A', 'A', to_date('2013-04-29 5:02:00 PM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-09 1:06:00 PM', 'yyyy-mm-dd hh:mi:ss am'), 'B');
insert into delme_unit_dates values ('123456', 'U1112', 'Unit A', 'B', to_date('2013-05-09 1:06:00 PM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-09 4:53:00 PM', 'yyyy-mm-dd hh:mi:ss am'), 'B');
insert into delme_unit_dates values ('123456', 'U1113', 'Unit A', 'B', to_date('2013-05-09 4:53:00 PM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-10 10:52:00 PM', 'yyyy-mm-dd hh:mi:ss am'), 't');
insert into delme_unit_dates values ('123456', 'U1114', ' unity, 't', to_date('2013-05-10 10:52:00 PM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-11 11:30:00 AM', 'yyyy-mm-dd hh:mi:ss am'), 'B' ");
insert into delme_unit_dates values ('123456', 'U1115', ' unity, ' B', to_date('2013-05-11 11:30:00 AM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-12 4:00:00 PM', 'yyyy-mm-dd hh:mi:ss am'), 'B');
insert into delme_unit_dates values ('123456', 'U1116', ' unity, ' B ', to_date('2013-05-12 4:00:00 PM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-16 2:14:00 PM', 'yyyy-mm-dd hh:mi:ss am'),' t ');
insert into delme_unit_dates values ('123456', 'U1117', 'Unit Z', ', to_date('2013-05-16 2:14:00 PM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-17 2:26:00 PM', 'yyyy-mm-dd hh:mi:ss am'), 'B');
insert into delme_unit_dates values ('123456 ', 'U1118', 'Unit Z', 'B', to_date('2013-05-17 2:26:00 PM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-20 11:30:00 AM', 'yyyy-mm-dd hh:mi:ss am'),');
insert into delme_or_dates values ('123456', 'OR2221', 'or 1', 'O', to_date('2013-05-09 7:35:00 AM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-09 10:56:00 AM', 'yyyy-mm-dd hh:mi:ss am'), 'R');
insert into delme_or_dates values ('123456', 'OR2222', ' 5', 'R', to_date('2013-05-09 10:56:00 AM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-09 3:20:00 PM', 'yyyy-mm-dd hh:mi:ss am'), 'U');
insert into delme_or_dates values ('123456', 'OR3331', 'or 2', 'O', to_date('2013-05-16 7:59:00 PM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-16 10:43:00 PM', 'yyyy-mm-dd hh:mi:ss am'), 'R');
insert into delme_or_dates values ('123456', 'OR3332', ' 8', 'R', to_date('2013-05-16 10:43:00 PM', 'yyyy-mm-dd hh:mi:ss am'), to_date('2013-05-17 11:20:00 PM', 'yyyy-mm-dd hh:mi:ss am'), 'U');
commit;
-Is far from what we
Select
U.*
, o.*
Of
delme_Unit_dates U
delme_OR_dates O
where
U.ID = o.id
and U.UNIT_IN_DTTM < = O.OR_IN_DTTM
and U.UNIT_OUT_DTTM > = O.OR_IN_DTTM
order of U.UNIT_IN_DTTM, O.OR_IN_DTTM
;
[/ code]
Post edited by: Jason_S (changed a single date ' 2013 - 05 - 16 15:20 ' to ' 2013 - 05 - 09 15:20 ')
Hi, Jason.
Jason_S wrote:
I edited one of the dates in the original post.
Also although the inpatient unit and OR events are contiguous for a given patient (no overlap and without gaps - after that data are cleaned).
...
The sample data you posted a of gaps in the data of the GOLD. It is correct that the solution below works or not there are gaps in the two tables.
WITH got_dttm AS
(
SELECT unit_in_dttm AS DTMC
OF delme_unit_dates
UNION
SELECT unit_out_dttm AS DTMC
OF delme_unit_dates
UNION
SELECT or_in_dttm AS DTMC
OF delme_or_dates
UNION
SELECT or_out_dttm AS DTMC
OF delme_or_dates
)
all_periods AS
(
SELECT DTMC AS in_dttm
, (DTMC) ahead OF (ORDER BY DTMC) AS out_dttm
OF got_dttm
)
SELECT NVL (u.id, o.id) as id
u.unit_rcd_id
u.unit_desc
u.unit_in_code
p.in_dttm
p.out_dttm
o.or_rcd_id
o.or_desc
Of all_periods p
LEFT OUTER JOIN delme_unit_dates u WE u.unit_in_dttm<=>=>
AND u.unit_out_dttm > = p.out_dttm
LEFT OUTER JOIN delme_or_dates o WE o.or_in_dttm<=>=>
AND o.or_out_dttm > = p.out_dttm
WHERE p.out_dttm IS NOT NULL
ORDER BY p.in_dttm
;
You can use the query above to CREATE or a CREATE TABLE... AS command.
If you have as much data as you say, a table or materialized view would be maybe faster to use.
You will notice that I do understand not all columns; I would like to know if you have a problem, including them.
I don't know what id role plays in this problem. It is difficult to say when all rows have the same value.
-
Importing a flat at Oracle and update another table
Hey everybody,
I am a newbie with Oracle, and I tried for 2 days to fix this below. But all my research and all attempts have failed.
I have a text file called ReturnedFile.txt. This is a comma separated text file that contains the records of two fields... Envelope and Date returned.
At the same time, I have a table in Oracle called manifest. This table contains the following fields:
Envelope
DateSentOut
DateReturnedI need to write something that matter the ReturnedFile.txt in a temporary Oracle table named UploadTemp and compares the data in the field of the envelope of UploadTemp with the domain of the envelope in the manifest. If it is a match, then the field of clear needs updated with field DateReturned in UploadTemp DateReturned.
I did it with SQL Server without problem, but I tried for two days to make it work with Oracle and I can't understand it. I tried to use SQL * Loader, but I can not even run properly on my machine.
I create a file of control, registered as RetFile.ctl. Here is the content of the CTL file:
DOWNLOAD THE DATA
INFILE 'C:\OracleTest\ReturnedFile.txt '.ADD
IN THE UploadTemp TABLE
"FIELDS TERMINATED BY '"
(
ENVELOPE,
DATERETURNED
)If I could get SQL * Loader works, here's the code I came with to import the text file, then compare it to the clear table and update if necessary:
sqlldr UserJoe/Password123 CONTROL=C:\OracleTest\RetFile.ctl LOG = RetFile.log BAD = RetFile.bad
update the manifest m set m.DateReturned =
(select t.DateReturned
of UploadTemp t
where m.Envelope = t.Envelope
*)That's all I had. As I said, I can't find a way to test it and I have no idea if it's still close.
Please... can anyone help me? Even close, I'm on this thing?
Joe
If your ReturnedFile.txtfile is a comma, you must FINISH BY ',' not COMPLETED BY "'" in your control file. If it happens to not be a comma ending on a line, then you must also add TRAILING NULLCOLS in your control file. You must also use a date format for your date in your control file that corresponds to the date format in your file ReturnedFile.txt, where it does not match the format of the date on your system. You must add a WHERE EXISTS clause in your update statement to prevent any lines that do not have the updated DateReturned with a null value. Please see the example below. If it doesn't then please do a copy and paste as I did, that includes a few lines of sample data and table structure. It would also be useful to see your SQL * Loader or logs SQL * Loader error message. If you can not get SQL * Loader is running properly, then you may have other issues, such as the permissions of files at the operating system level. Also, there are options other than the methods below. For example, you can use an external table, instead of SQL * Loader, if your ReturnedFile.txtfile is on your Serer, not your client. You can also use the merger instead of update.
Scott@orcl_11gR2 > type host returnedfile.txt
enV2, 07/03/2013
ENV3, 07/04/2013
ENV4, 07/05/2013
Scott@orcl_11gR2 > type host retfile.ctl
DOWNLOAD THE DATA
INFILE 'ReturnedFile.txt '.
ADD
IN THE UploadTemp TABLE
FIELDS TERMINATED BY ', '.
trailing nullcols
(ENVELOPE
DATERETURNED date "yyyy-mm-dd")
Scott@orcl_11gR2 > create table uploadtemp
2 (envelope varchar2 (15),)
date of datereturned 3)
4.
Table created.
Scott@orcl_11gR2 > create clear table
2 (envelope varchar2 (15),)
3 date of DateSentOut,
4 date of DateReturned)
5.
Table created.
Scott@orcl_11gR2 > insert all
2 in manifests values ("env1", sysdate-7, sysdate-3)
3 in obvious values ("env2", sysdate-6, null)
4 in the obvious values ('env3' sysdate-5, null)
5 Select * of the double
6.
3 lines were created.
Scott@orcl_11gR2 > select * from manifest
2.
ENVELOPE DATESENTO DATERETUR
--------------- --------- ---------
ENV1 June 28, 13 2 July 13
enV2 29 June 13
ENV3 30 June 13
3 selected lines.
Scott@orcl_11gR2 > host sqlldr scott/tiger CONTROL = RetFile.ctl LOG = RetFile.log BAD = RetFile.bad
SQL * Loader: release 11.2.0.1.0 - Production on Fri Jul 5 13:15:06 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit the point reached - the number of logical records 3
Scott@orcl_11gR2 > select * from uploadtemp
2.
ENVELOPE DATERETUR
--------------- ---------
enV2 3 July 13
ENV3 4 July 13
ENV4 July 5, 13
3 selected lines.
Scott@orcl_11gR2 > clear day m
2. set m.DateReturned =
3 (select t.DateReturned
4 t UploadTemp
5 where m.Envelope = t.Envelope)
6 where there is
7 (select t.DateReturned
UploadTemp 8 t
9 where m.Envelope = t.Envelope)
10.
2 lines to date.
Scott@orcl_11gR2 > select * from manifest
2.
ENVELOPE DATESENTO DATERETUR
--------------- --------- ---------
ENV1 June 28, 13 2 July 13
enV2 June 29, 13 3 July 13
ENV3 June 30, 13 4 July 13
3 selected lines.
Maybe you are looking for
-
Airport to Airport utility express extender
I am a little concerned about what I read, trying to research on this problem. She was told that I could extend my wi - fi with a second Airport Express Terminal. But it will not be displayed in the utility. And I read that it extends only to Apple p
-
Hello. Anyone knows where can I find changelogs for the latest version of Skype for Linux (4.2.0.13)?
-
I can't fix the sentence 80070424, do work all of the MS solutions
I have a Dell 1545 whit Vista 64, but start it since, I can't access to windows updates, because theerror 80070424, I try all the solutions recommended but is time to waist, I don't download any application and the results are the same
-
keyboard driver stuck on start or restart because he is known to have problems (code 48)
using the model of toshiba C670 win7 tapping the screen with keyboard
-
changing the oraInventory when installing grid location
Hello Experts,We have existing UNIX (AIX) server on which we have several database installed before long & so central inventory location is located in the first installation of the database that was created with a different user than oracle.Now we wa