Questions tagged [virtual-columns]

19 questions
6
votes
1 answer

Find columns referenced by virtual column expression

Does anyone know of any Oracle dictionary views that hold references of 'real' columns to virtual columns? For example lets say I have a table like this: create table t ( c1 varchar2(5) ,c2 as (c1 || '*') ) I'm after a way of determining that c1…
Horrendo
  • 161
  • 1
  • 3
4
votes
4 answers

Is (and if how) it possible in Oracle to "insert into values " if
has virtual columns
Here's a table create table tq84_virtual_test_without ( col_1 number, col_2 number, col_3 number, col_4 number, col_5 number ); with the rule that col_5's value is the sum of the other four columns. So the table is filled…
René Nyffenegger
  • 3,763
  • 7
  • 32
  • 39
4
votes
1 answer

Oracle random number as default column value

I'm trying to create a table in OracleDB and assign random number to one of the columns as a default. I have this setup working in postgresql create table table_name ( column integer NOT NULL DEFAULT (random()) ) how can I do something similar…
KianTern
  • 41
  • 2
4
votes
1 answer

How do MySQL 5.7 virtual columns differ from views?

Starting reading point: https://www.percona.com/blog/2015/04/29/generated-virtual-columns-in-mysql-5-7-labs/ Running some tests with the most recent percona 5.7 they seem to work well. Explain plans and wall time look pretty good but I'm not seeing…
atxdba
  • 5,293
  • 5
  • 41
  • 62
3
votes
3 answers

How to use column alias to calculate other column value

My query is SELECT (`house_rent`+`conveyance`+`medical`+`dearness`+`others_allowances`) AS earnings ,(`income_tax`+`pro_tax`+`emp_state_insu`+`absence_fine`+`others_deductions`) AS deductions ,(earnings - deductions) AS net_salary…
Tanveer Jafri
  • 35
  • 1
  • 1
  • 4
2
votes
1 answer

Can not drop virtual column | ERROR 1054 (42S22): Unknown column in 'GENERATED ALWAYS'

I'm just running a command: optimize table some_table_name_here; But it results with: Table | Op | Msg_type | Msg_text db.some_table_name_here | optimize | note | Table does not support optimize, doing recreate + analyze…
iorsa
  • 31
  • 4
2
votes
2 answers

Concatenate multiple columns into one column (,) separated

In SQL database that stores Images in a parcelImages table.Since each parcel can take part in multiple Images and each images can involve multiple parcels. I want to get each parcel having Image value with comma separated values as shown above I…
Jubert
  • 23
  • 1
  • 1
  • 3
1
vote
2 answers

Constant values in columns

I have a SQL Server 2000 database used by our ERP system. There are many columns that always have the same value. A table row is really huge, potentially exceeding the maximum row size in SQL Server 2000 (8kB). I'm thinking about replacing these…
1
vote
0 answers

Is it possible to alter normal column to virtual column in Oracle?

ALTER TABLE TAB_NAME ADD TEST_COL VARCHAR2(255); ALTER TABLE TAB_NAME MODIFY TEST_COL GENERATED ALWAYS as ('some_exp') VIRTUAL; Second script gives an error: Error report - ORA-54026: Real column cannot have an expression 54026. 0000 - "Real…
Raushan
  • 113
  • 2
1
vote
0 answers

Does MySQL update indexes on virtual columns on tables that are being replicated from a master?

We use statement based bin log master-slave replication with MySQL 5.7. We use the slave for analytics and so add additional indexes and things not required on the master. I recently tried to add a virtual column and indexed it. Unfortunately, it…
km6zla
  • 111
  • 3
1
vote
1 answer

Creat Temporary Id in SQL Statement

I have a table id name 1 Alpha 2 Alpha 3 Beta 4 Charlie 5 Charlie I want to assign a temporary id at the run time in the SQL statement, So the desired result should be like myid name 1 Alpha 2 Beta 3 Charlie So basically the…
neeraj
  • 260
  • 3
  • 8
0
votes
1 answer

Database engine that share a row among multiple tables

I'm wondering whether exists any database engine that can share cells or rows amongst many tables. For example: TABLE Customer ( CID: int Fullname: nvarchar(50) Age: int ) TABLE Group ( GID: int Name: nvarchar(50) ) TABLE…
0
votes
1 answer

how to add a query to postgres and have it show up as a table

I'm not sure what technology I need because I'm not a DBA, but I'm sure there's a good way to do this. I have a postgres database with this schema (top two tables exist): So I'm trying to add the 3rd table to the database. It's a subset of…
0
votes
1 answer

Intended use case for virtual columns with function-based index?

What is the intended use case for virtual columns with a function-based index? The reason I ask (novice): I've been exploring options for pre-computing columns in a table. For example, in a roads table, populate a field using the…
User1974
  • 1,517
  • 25
  • 54
0
votes
1 answer

Adding Virtual Column after column x is very slow

In our environment, we usually add and drop generated columns every now and then. There is a very large table in the database with more than 3 million rows and adding/removing column was extremely slow. We opted to change the generated column from…
Ali
  • 345
  • 3
  • 17
1
2