Convert a Non-virtual virtual column
Can I convert a virtual column in a non-virtual (ordinary scalar column) or what I have to delete and recreate?
for example, I have a virtual column defined as:
exam_length NUMBER GENERATED ALWAYS AS ("TOTAL_SESSION_LENGTH"-NVL("TUTORIAL_LENGTH",0)-NVL("SURVEY_LENGTH",0) "")
and I just want to:
exam_length NUMBER (10.0)
I tried:
ALTER TABLE my_table () CHANGE
EXAM_LENGTH NUMBER (10,0))
/
... but that just change the data type and keeps virtual with the product still intact clause
You would have to
a. Add a new column (regular)
b. copy the virtual column to the new column data
c. drop the virtual column
d. rename the new column
Hemant K Chitae
Tags: Database
Similar Questions
-
Interval partitioning using the key of the virtual column
Hi guys
I have a series of tables that I propose to the partition.
Each table has a year and a period (equivalent to a month) and I intend using those as my partition keys - year as the partition and the period as the subpartition.
The distribution will be actually:
2015
001
002
...
012
2016
001
002
...
012
etc...
I would use range partitioning for the year, because it would make the maintenance of the partition a breeze. Only one problem - the field is of type varchar, and is not modifiable as its legacy applications that have become bigger than Ben Hurr and more tangled than a Ben Hurr size flat spaghetti.
It is hence the idea of virtual column between in game - I could create a virtual column in these tables to convert the field to digital and then partition on it instead.
My question-if the year of origin varchar column is included in the where clause of a query, is the optimizer based on CSSTidy smart enough to realize that the virtual column used for the partition key is based on this column and use pruning of partition to improve performance? Or queries must refer to the virtual column to make it work? Also, the virtual column should be indexed to make it work?
Thanks in advance.
Simon
orclz >
orclz > create table pt (v1 varchar2 (1) c1 as (to_number (v1)), number of c2)
2 partition by range (c1) interval (1)
subpartition by hash (c2) subpartitions 4 3
4 (partition p1 values less than (1))
5.
Table created.
orclz > set autot on explain
orclz > select * PT where v1 = '0';
no selected line
Execution plan
----------------------------------------------------------
Hash value of plan: 711571056
--------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
--------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 82. 2296 | 29 (0) | 00:00:01 | | |
| 1. RANGE OF PARTITION ALL THE | | 82. 2296 | 29 (0) | 00:00:01 | 1. 1048575.
| 2. HASH PARTITION ALL | | 82. 2296 | 29 (0) | 00:00:01 | 1. 4.
|* 3 | TABLE ACCESS FULL | PT | 82. 2296 | 29 (0) | 00:00:01 | 1. 1048575.
--------------------------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
3 - filter ("V1" = '0')
orclz > select * PT where c1 = 0;
no selected line
Execution plan
----------------------------------------------------------
Hash value of plan: 1726115854
-----------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 82. 2296 | 29 (0) | 00:00:01 | | |
| 1. RANGE OF SINGLE PARTITION | | 82. 2296 | 29 (0) | 00:00:01 | 1. 1.
| 2. HASH PARTITION ALL | | 82. 2296 | 29 (0) | 00:00:01 | 1. 4.
|* 3 | TABLE ACCESS FULL | PT | 82. 2296 | 29 (0) | 00:00:01 | 1. 4.
-----------------------------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
3 - filter ("C1" = 0)
--
John Watson
Oracle Certified Master s/n
-
json_list to varchar/string to use in the virtual column
Hello Experts,
Environment:
Database Oracle 12 c Enterprise Edition Release 12.1.0.2.0 - 64 bit Production
PL/SQL Release 12.1.0.2.0 - Production
I have the following function that returns JSON_LIST.
{code}
CREATE OR REPLACE FUNCTION GENERATE_JSON (STRING2CONVERT IN VARCHAR2)
RETURN JSON_LIST
DETERMINISTIC
IS
RET json_list;
V_ERROR VARCHAR2 (31000);
BEGIN
RET: = json_dyn.executeList (STRING2CONVERT);
RET. Print;
RETURN RET;
EXCEPTION WHEN OTHERS THEN
V_ERROR: = SQLERRM;
RETURNS A NULL VALUE.
END;
-test the query see the output in the output of DBMS
SELECT GENERATE_JSON (' select ' |) Chr (39) | ' AJ' | Chr (39) |' like c_name,' | Chr (39) | ' BOY ' | Chr (39): ' c_type, like '
|| Chr (39) | ' HUMAN '. Chr (39): ' as c_category,' | Chr (39) | ' TEST SUBJECT ' | Chr (39) | 'as c_desc from dual')
FROM DUAL;
{code}
The SQL query above in the DBMS output output
[{
"C_NAME": "AJ."
"C_TYPE": "BOY."
"C_CATEGORY": "HUMAN."
'C_DESC': 'GUINEA PIG '.
}]
Question: How can I have it return the same structure of String (varchar).
Why would I want to convert JSON_LIST to string?
So that I can use this call to service as part of a virtual column in a table to store Json and have a constraint to enforce structureof Json.
If this is not the right way?
Kindly share how I can take a few columns in the same table, convert to json format and store in a virtual column in the same table and enforce the Json structure?
Thank you
AJ
with
data in the form of
(select q'~ select "AJ" as c_name, 'BOY' as c_type, 'HUMAN' as c_category, 'SUBJECT of TEST' as the double c_desc ~' source)
of the double
),
Converter (SRC, res, Step) as
(select regexp_replace (ltrim (upper (substr (source, 1, instr (upper (source), "FROM") - 1)), "SELECT"), '\s+AS\s+',': ') |) ',', null, 1
from the data
Union of all the
Select substr (src, instr(src,',') + 1)
'"' || substr (substr (SRC, 1, InStr (CBC, ',') - 1), instr (substr (src, 1, instr (CBC, ',') - 1),': ') + 1) | '" : ' ||
Replace (substr (substr (SRC, 1, InStr (CBC, ',') - 1), 1, instr (substr (src, 1, instr (CBC, ',') - 1),': ')-1), "','" ' "),
Step + 1
converter
where the CBC is not null
)
Select the source'[{' | listagg(res,',') Group (order by step) |}] '] "converted
data converter
SOURCE CONVERTED Select "AJ" as c_name, 'BOY' as c_type, 'HUMAN' as c_category, 'SUBJECT of TEST' as double c_desc [{'C_NAME': 'AJ', 'C_TYPE': 'BOY', 'C_CATEGORY': 'HUMAN', 'C_DESC': 'GUINEA PIG'}] Concerning
Etbin
-
Addition of virtual column: ORA-12899: value too large for column
I am using Oracle 11g, OS Win7, SQL Developer
I'm trying to add the virtual column to my test table, but get ORA-12899: value too large for column error. Here are the details.
Can someone help me in this?
CREATE TABLE test_reg_exp (col1 VARCHAR2(100)); INSERT INTO test_reg_exp (col1) VALUES ('ABCD_EFGH'); INSERT INTO test_reg_exp (col1) VALUES ('ABCDE_ABC'); INSERT INTO test_reg_exp (col1) VALUES ('WXYZ_ABCD'); INSERT INTO test_reg_exp (col1) VALUES ('ABCDE_PQRS'); INSERT INTO test_reg_exp (col1) VALUES ('ABCD_WXYZ');
When I try to, I get the correct results:ALTER TABLE test_reg_exp ADD (col2 VARCHAR2(100) GENERATED ALWAYS AS (REGEXP_REPLACE (col1, '^ABCD[A-Z]*_'))); SQL Error: ORA-12899: value too large for column "COL2" (actual: 100, maximum: 400) 12899. 00000 - "value too large for column %s (actual: %s, maximum: %s)" *Cause: An attempt was made to insert or update a column with a value which is too wide for the width of the destination column. The name of the column is given, along with the actual width of the value, and the maximum allowed width of the column. Note that widths are reported in characters if character length semantics are in effect for the column, otherwise widths are reported in bytes. *Action: Examine the SQL statement for correctness. Check source and destination column data types. Either make the destination column wider, or use a subset of the source column (i.e. use substring).
Thank you.SELECT col1, (REGEXP_REPLACE (col1, '^ABCD[A-Z]*_')) FROM test_reg_exp;
Yes, RP, it works if you give col2 size > = 400.
@Northwest - could you please test the same w/o having a clause of regex in col2?
I have a doubt about using a REGULAR expression in this case Dynamics col.Refer to this (might help) - http://www.oracle-base.com/articles/11g/virtual-columns-11gr1.php
Below excerpt from above link... see if that helps...
>
Notes and restrictions on the virtual columns include:The indexes defined on the virtual columns are equivalent to a function-based index.
Virtual columns can be referenced in the updates and deletions WHERE clause, but they cannot be manipulated by DML.
The tables containing virtual columns may still be eligible for result caching.
Functions in expressions must be deterministic when the table is created, but can then be recompiled and non-deterministic without for as much invalidate the virtual column. In such cases, the following steps must be taken after the function is recompiled:
Constraint on the virtual column must be disabled and re-enabled.
On the virtual column indexes must be rebuilt.
Materialized views that access the virtual column must be fully refreshed.
The result cache must be flushed if the virtual column acceded to the request (s).
Statistical table must be regathered.
The virtual columns are not supported for the organized and external object in index, cluster or temporary tables.
The expression used in the virtual column definition has the following restrictions:
It cannot refer to another virtual column by name.
It can refer to the columns defined in the same table.
If it refers to a deterministic user-defined function, it cannot be used as a partitioning key column.
The result of the expression must be a scalar value. It cannot return that an Oracle supplied the data type, a type defined by the user, LOB or LONG RAW.
>Published by: Vanessa B on October 16, 2012 23:48
Published by: Vanessa B on October 16, 2012 23:54
-
ORA-01733-virtual column not allowed here - insert using inline view
Does anyone know why I get ORA-01733-virtual column not allowed here
SQL > select * from v version $;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
AMT for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
-no error without the WITH CHECK option
SQL > INSERT INTO
2 (SELECT
3 location_id,
4 city
5 l.country_id
6 OF country c, localities, regions r l
7 where l.country_id = c.country_id
8 and c.region_id = r.region_id
9 and r.region_name = 'Asia')
10 VALUES (5500, 'Common Wansdworth', 'UK');
1 line of creation.
SQL > rollback;
Complete restoration.
-error with WITH CHECK OPTION
SQL > INSERT INTO
2 (SELECT
3 location_id,
4 city
5 l.country_id
6 OF country c, localities, regions r l
7 where l.country_id = c.country_id
8 and c.region_id = r.region_id
9 and r.region_name = 'Asia' WITH CHECK OPTION)
10 VALUES (5500, 'Common Wansdworth', 'UK');
INSERT INTO
*
ERROR on line 1:
ORA-01733: virtual column not allowed here
I was expecting
ORA-01402: discovers the violation of where WITH CHECK OPTION clause
for the second. Am I missing here?Coskan wrote:
RandolfThanks a lot for the update of this old question
After reading the link, I think I should ignore this error and accept him as ORA-01402The information that you have asked me to check me do not have an understanding of the different error types.
Coskan,
I didn't know this is an old thread that somehow got updated by someone else.
Regarding your question: you're right that the output of the script is not really that useful.
I have just run on 10.2.0.4 and in general, it seems that the output of USER_UPDATABLE_COLUMNS is incorrect regarding the views of join using the WITH CHECK OPTION.
For example although the location_id from the TEST_V_2 column appears as non-editable (probably because of the rule that "the columns used in the join expression" cannot be modified in a join view when you use the WITH CHECK OPTION) I can run successfully your insert if statement I choose a location_id less than 2000.
It seems that summed up the difference if you join more than two tables, you'll always get the error "ORA-01733" when you try to insert in the join with the enabled OPTION CHECK view. For example to add a third table TEST_V_2 which does not change the original view, but simply joined meaning for example COUNTRIES to LOCATIONS, will show the same behavior to throw an ORA-01733, however it works fine when the omission of the WITH CHECK OPTION.
So overall, I tend to say it is really a limitation of the implementation and it is not actually an ORA-01402 but looks like Oracle is simply trying to tell you: Amendment No. INSERT in this possible view. Updates however seem to work, at least I can find some examples of work.
There seems to be other restrictions of implementation with the WITH CHECK OPTION in place even when the only membership as two tables, for example when trying to join the COUNTRIES and PLACES but by selecting only in PLACES and by using a filter on the COUNTRY_ID predicate fails with ORA-01733 when this predicate is applied to the COUNTRY. COUNTRY_ID but it works if this predicate is applied to PLACES. COUNTRY_ID.
I could imagine that Oracle has quietly added some of these restrictions with each patch set due to the angle of the case/adverse reactions encountered. I saw this for other features, too.
Kind regards
RandolfOracle related blog stuff:
http://Oracle-Randolf.blogspot.com/SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676 /.
http://sourceforge.NET/projects/SQLT-pp/ -
ORA-54017: excluded from the regime of virtual columns UPDATE Operation
Referenced to
There are problems with v4.0_4.121.1.0 knew?
Thank you
Sorry, but after setting
StoreGeneratedPattern
toComputed
in the EF model I have the same problem.Thank you
-
Hi all
Here is the create table script, which does not work, error ORA-12899 keep expressing. Please suggest...,.,.
CREATE TABLE FX_TRANS
(
SAGE_TRADE_TYPE VARCHAR2 (50 BYTE),
UPSTREAM_EXECUTION_TS TIMESTAMP (9).
LOCAL_TZ VARCHAR2 (20 BYTE),
GMT_CONV_ENTERED_DT_TS TIMESTAMP (9) ALWAYS GENERATED IN THE FORM ("SONARDBO". "FN_CONVERT_TIMEZONE"("LOCAL_TZ","ENTERED_DT_TS")), "
GMT_CONV_EXECUTION_DT_TS TIMESTAMP (9) ALWAYS GENERATED IN THE FORM ("SONARDBO". "FN_CONVERT_TIMEZONE"("LOCAL_TZ","UPSTREAM_EXECUTION_TS")), "
);[Error] Running (5:3): ORA-12899: value too large for column 'GMT_CONV_EXECUTION_DT_TS' (actual: 11, maximum: 20)
[Error] Performance (6:3): ORA-12899: value too large for column 'GMT_CONV_EXECUTION_DT_TS' (actual: 11, maximum: 20)
Used fucntion Script that I use as a VIRTUAL column expression:CREATE OR REPLACE FUNCTION SONARDBO. FN_CONVERT_TIMEZONE
(
PI_LOCAL_TZ IN VARCHAR2,
PI_DT IN TIMESTAMP
)
RETURNS THE TIMESTAMP
DETERMINISTIC
IS
LV_TIMESTAMP TIMESTAMP;
BEGIN
LV_TIMESTAMP: = CASE WHEN PI_LOCAL_TZ = 'SERGEANT' THEN
TO_TIMESTAMP (TO_CHAR)
((FROM_TZ)
PI_DT,
"Asia/Singapore")
IN THE ZONE IS "GMT"),.
'YYYY-MM-DD HH. FF H '),'YYYY-MM-DD HH. TZDS FF PM ")"
WHEN PI_LOCAL_TZ = "GMT" THEN
TO_TIMESTAMP (TO_CHAR)
((FROM_TZ)
PI_DT,
"GMT")
IN THE ZONE IS "GMT"),.
'YYYY-MM-DD HH. FF H '),'YYYY-MM-DD HH. TZDS FF PM ")"
WHEN PI_LOCAL_TZ = "IS" THEN
TO_TIMESTAMP (TO_CHAR)
((FROM_TZ)
PI_DT,
"America/New_York")
IN THE ZONE IS "GMT"),.
'YYYY-MM-DD HH. FF H '),'YYYY-MM-DD HH. TZDS FF PM ")"
ANOTHER NULL
END;
RETURN LV_TIMESTAMP;
EXCEPTION
WHILE OTHERS THEN
LIFT;
END;
/Thank you very much
Arpit
This one worked for me.
-----------------
drop table FX_TRANS; CREATE TABLE FX_TRANS ( SAGE_TRADE_TYPE VARCHAR2 (50 BYTE), UPSTREAM_EXECUTION_TS TIMESTAMP (9), LOCAL_TZ VARCHAR2 (20 BYTE), ENTERED_DT_TS TIMESTAMP (9), GMT_CONV_ENTERED_DT_TS timestamp(9) GENERATED ALWAYS AS (cast ("FN_CONVERT_TIMEZONE" ("LOCAL_TZ", "ENTERED_DT_TS") as timestamp(9))), GMT_CONV_EXECUTION_DT_TS timestamp(9) GENERATED ALWAYS AS (cast("FN_CONVERT_TIMEZONE" ("LOCAL_TZ", "UPSTREAM_EXECUTION_TS") as timestamp(9)))); INSERT INTO fx_trans (SAGE_TRADE_TYPE, UPSTREAM_EXECUTION_TS, LOCAL_TZ, ENTERED_DT_TS) VALUES ('A', SYSTIMESTAMP, 'SGT', SYSTIMESTAMP + 1 / 24); commit;
------------
See you soon,.
Manik.
-
Hi all
Here is the structure of the table with two expression of virtual columns associated highlighted, now I want to delete these expressions with virtual columns (but must keep my VIRTUAL columns as it is).
Is it possible the alter or I need to raise the table, make a new structure and copy content back to newly structured table... Pleae help!
CREATE TABLE TEST_COL)
SAGE_TRADE_TYPE VARCHAR2 (50 BYTE),
LOCAL_TZ VARCHAR2 (20 BYTE),
ACE GMT_CONV_ENTERED_DT_TS (SAGEDBO. FN_CONVERT_TIMEZONE (LOCAL_TZ, ENTERED_DT_TS)) VIRTUAL,.
ACE GMT_CONV_EXECUTION_DT_TS (SAGEDBO. FN_CONVERT_TIMEZONE (LOCAL_TZ, UPSTREAM_EXECUTION_TS)) VIRTUAL,.
EOD_IND VARCHAR2 (10 BYTE)
);
Thank you very much
Arpit
Try this
ALTER table test_col change gmt_conv_entered_dt_ts (0) virtual;
ALTER table test_col change gmt_conv_execution_dt_ts (1) virtual;
-
ORA-54002 on creating virtual column
I wonder on what follows.
I'm in the middle of a migration project.
I load the data received from the source database into the staging tables.
The data in these tables must remain absolutely intact to be able to check where things have gone wrong if something is not the way we expected after migration.
Obviously, the data includes dates. Those who are in the DATE data type columns.
However, the values represent the date and time UTC.
The values are NOT timestamps with time zone, but simply date that contains the date time and something that has passed, but expressed in the date and time utc.
Now, the database target also expects that DATEs, so I seem to be home free.
However, the target database expect the passage of time to express the time zones (Europe/Amsterdam).
No problem I know how to do this.
And because I want to do a million times in the transformation before insertion in the target code (and almost certainly forget a few times) I thought: I'll add virtual columns for the staging tables that allow to calculate the local time of the date and time utc.
This way the data is intact, but the transformation code can simply use the column (virtual) replacement and does not bother with the calculations of time.
Great, I thought.
Until I tried to create the table.
CREATE TABLE utc_test
(createddate_utc DATE
createddate GENERATED DATE ALWAYS
AS (CAST (FROM_TZ (CAST (createddate_utc AS TIMESTAMP)
, "UTC".
)
At the time of the ZONE "Europe/Amsterdam".
AS DATE
)
)
VIRTUAL
);
And Oracle says:
At the time of the ZONE "Europe/Amsterdam".
*
ERROR on line 7:
ORA-54002: only pure functions can be specified in a virtual column expression
Excuse me?
Not deterministic?
Oracle is probably right, and even if it isn't yet I have to live with that.
But no matter how hard I try I can't understand why this code would not deterministic.
IMHO any form of date I put in createddate_utc, if I put the same date in here a million times I'll get the same answer a million times.
I know, FROM_TZ to the ZONE SCHEDULE will give different answers for different time zones.
But not for a same time zone.
And is this not the essence of deterministic: always the same result, given the same input?
Anyone who can teach me Oracle ;-)
My question (I may not was clear on that) was: why Oracle claims that the function is not deterministic?
Because this is not the case.
Zone information (and therefore the conversion between TZs) are governed by the zone files, see: Datetime and time zones Support Data Types.
Since these data may vary, it is not deterministic.
To solve this 'problem', you can always create a standalone function transformation of packaging and declare it deterministic, even if it is not in the strict sense.
-
Function index and virtual columns
I just read the documentation of Oracle on the FBI. In the context of optimization with a function-based index, it is said that "a virtual column is useful for speed of access to data from expressions.". Here is the link Index-Organized Tables and indexes.
My question is, does Oracle already not create a virtual column when we create a function-based index?
Concerning
Charlie
Hi CharlieYes, the database engine creates a virtual column. But this column is hidden. Reproduced in 11.2.0.3 example:SQL> CREATE TABLE t (n NUMBER);SQL> CREATE INDEX i ON t (round(n,0)); SQL> SELECT column_name, hidden_column, virtual_column 2 FROM user_tab_cols 3 WHERE table_name = 'T'; COLUMN_NAME HIDDEN VIR ------------------------------ ------ --- N NO NO SYS_NC00002$ YES YES
HTH
Chris Antognini
Troubleshooting performance Oracle, Apress 2008/2014
-
ORA-00936: missing expression when adding virtual column
I am having this error when you add virtual column am in database 11 g
having error
ORA-00936: lack of expression
in select superior
My sql is
Employees ALTER TABLE ADD (user name (select upper (substr (first_name, 1, 1)) | initcap (last_name) user name of employees));
http://docs.Oracle.com/CD/E11882_01/server.112/e41084/statements_3001.htm#sthref3374
Adding a column of Table virtual: example, the following statement adds a copy of the
hr.employees
table a column namedincome
, which is a combination of salary more commission. Wages and the commission areNUMBER
columns, so the database creates the virtual column as aNUMBER
same column if the data type is not specified in the statement:CREATE TABLE emp2 AS SELECT * FROM employees; ALTER TABLE emp2 ADD (income AS (salary + (salary*commission_pct)));
ALTER TABLE ADD employees (AS username (upper (substr (first_name, 1, 1)) | initcap (last_name)));
Concerning
Etbin
-
Adding a virtual column derived from sdo_geometry?
Hi guys - maybe just a quick: do I do specifically to add a virtual as column the based on a geometry object?
SQL> select * 2 from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Linux: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production 5 rows selected. SQL> create table foo (id number 2 ,locn mdsys.sdo_geometry); Table created. SQL> SQL> alter table foo add (x number as (locn.sdo_point.x)); alter table foo add (x number as (locn.sdo_point.x)) * ERROR at line 1: ORA-54016: Invalid column expression was specified
I know that in a query, the table must be qualified with an alias as below:
don't know how to apply this to a virtual column.
SQL> insert into foo values (1,MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(151.213376,-33.865623,NULL),NULL,NULL)); 1 row created. SQL> select * 2 from 3 SQL> SQL> SQL> select f.locn.sdo_point.x 2 from foo f; LOCN.SDO_POINT.X ---------------- 151.213376 1 row selected. SQL>
Edit: what should we do to make the display in a fixed rate code in shape with a police?
For me it works with a user defined function:
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production PL/SQL Release 11.2.0.2.0 - Production CORE 11.2.0.2.0 Production TNS for 32-bit Windows: Version 11.2.0.2.0 - Production NLSRTL Version 11.2.0.2.0 - Production SQL> create table foo (id number 2 ,locn mdsys.sdo_geometry); Table created. SQL> insert into foo (id, locn) values (1,MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(151.213376,-33.865623,NULL),NULL,NULL)); 1 row created. SQL> create or replace function get_geometry_x (g mdsys.sdo_geometry) return number deterministic as 2 begin 3 return g.sdo_point.x; 4 end; 5 / Function created. SQL> alter table foo add (x number as (get_geometry_x(locn))); Table altered. SQL> select x from foo; X ---------- 151,213376
Message geändert durch hm
-
details of the virtual columns and deterministic function
Hello
First time that I post a question after the migration of the Forums. So please excuse me if you see errors in format.
Below, I have created a function as deterministic and a table with a virtual column (column refers to the function)
Here are my questions
(1) if I run SELECT * FROM t whenever Oracle will perform the function add_fn?
(2) what is the advantage of DETERMINISTIC? (Documentation says that if we declare a function as deterministic he will attempt to use previously caluculated results for the same set of values. So, when I ever I run SELECT * FROM t oracle executes add_fn only once and it will use the result for the next time. Is my understanding correct.)
Here's the code.
SQL> create or replace function add_fn ( p_n1 in number 2 ,p_n2 in number ) 3 return number deterministic 4 is 5 begin 6 return p_n1+p_n2; 7 end; 8 / Function created SQL> create table t ( n1 number 2 ,n2 number 3 ,n3 number generated always as (add_fn(n1,n2)) virtual 4 ); Table created SQL> insert into t (n1,n2) values (10,20); 1 row inserted SQL> select * from t; N1 N2 N3 ---------- ---------- ---------- 10 20 30 SQL> select * from t; N1 N2 N3 ---------- ---------- ---------- 10 20 30 SQL>
Hello
...
(1) if I run SELECT * FROM t whenever Oracle will perform the function add_fn?(2) what is the advantage of DETERMINISTIC? (Documentation says that if we declare a function as deterministic he will attempt to use previously caluculated results for the same set of values. So, when I ever I run SELECT * FROM t oracle executes add_fn only once and it will use the result for the next time. Is my understanding correct.)
...
(1) oracle will have to evaluate the function. Because only deterministic functions are allowed, this means that it will not necessarily perform the function again; He can get the value cached from a previous call.
I think that the indexed values are actually stored in the index. "SELECT * FROM t;" do not use an index, but if you make another request, then you should be able to get the value of the virtual table of the index, without calling the function or obtaining the value of a cache.
(2) If a function is DETERMINISTIC, the optimizer may decide whether to actually call the function each time, or the cache for better performance results. There is no guarantee that it will always be one or the other. Replace "will be" in your description "may", and then what you say is correct.
-
Is it possible to install Vmware converter in a virtual machine?
Hello
I would like to know if its possible to install VMware converter in one machine virtual host Xen (WinXP)? We must find a way to convert a Xen virtual machine and import it into an ESX environment. So my first plan was to mount a hard drive of the virtual machine Xen host and install VMware converter.
Unless there is an easier way to do it.
Appreciate any feedback...
Thank you.
Hi Jakepp,
You can use VMware Converter to transform your XEN VM for VMware. You can take a look at the following kb to confirm:
Good luck.
Concerning
Franck
-
Hello
There is some support planning add/edit the virtual columns?
Kind regards.Hi, Giuseppe.
Some information on the support of the virtual column (first available in Oracle 11 g Release 1) with SQL Developer.
In the current version of the production, 3.2.20.09.87, manifested a definition of existing virtual column in the column default data tab of columns from the display of table help Add Action of the tab, there is no way to set a virtual column. Using the Edit from the context menu of the node of the table option, try to change a virtual column (or add a new virtual column) by updating the default text box will fail with something like the following error message:
Invalid
Default Value Expression cannot use columns or user functions. Literal strings should be quoted.... Looking the next development version, it seems that the user of Table Edit interface has been enhanced to include support for virtual column; However, trying to use the parser actually complained to virtual column expression is not valid. Maybe this improvement does not hangs properly still. Our Quality Assurance is aware of the issue and will record a bug later in the development cycle if the developer intercepts her.
Kind regards
Gary
SQL development team
Maybe you are looking for
-
How keep the paths with LV, I am looking for the way to store paths?
I'm looking for ways to store paths, so that when I run a VI requiring this way, I don't have to set it. What I want is to establish once > store it > open a VI who select automatically. I have an example, but it gives a bad result.
-
Hello all ~ I use the labview and NI GPIB-USB-HS card to control the Agilent N8736 DC supply. The goal: I want the output voltage 24V, then unmold to 9V, then mounted to 24V, the rise time and the fall time must be less than 10 ms. The issue: how to
-
I tried to attach two pictures to this advert, but cannot see if they appear correctly in the preview. The D820 with Nvidia GPU and WUXGA screen shows a white band which does not change regardless of the resolution of the screen, the BIOS boot scree
-
error code in live movie maker ox800488fa
Live Movie Maker will not download to facebook ot utube what he comes back with the error code ox800488fa
-
Can someone tell me please how to change the TEMP environment variable in Windows 8 on a Surface?