Questions tagged [view]

A virtual table that represents the data in one or more tables in an alternative way.

Filter by
Sorted by
Tagged with
-1
votes
1answer
146 views

How are database views executed?

Lets assume there is a design where every table is represented by a view, that is simply selecting all of the columns of the table and all the rows. --vw Select * From sys_table And I then run a ...
0
votes
0answers
79 views

Cannot DROP/ALTER a VIEW because other objects depend on it

I need to ALTER a VIEW in order to add an additional field but I am unable to alter/drop it because other objects (several functions and views) depend on it. Is there any way to alter the view without ...
4
votes
1answer
301 views

Cannot use "ON CONFLICT" with postgres updatable view and partial index

I have an updatable view pointing to an underlying table that has a partial index. It looks something like this CREATE TABLE if not exists foo ( a INT, b INT, x INT, y INT, z ...
0
votes
1answer
32 views

SQL Server 2008 - Replacing csv substrings in view-row using data from other table

Using SQL server 2008, is there a way to perform SELECT query in a view replaces a row containing comma-separated values with their corresponding text value from another table? STRING_SPLIT and ...
0
votes
0answers
55 views

Look Up Table for View, or Relation

Setup I designed a database scheme which purpose it is to act as a foundation for testing a System under Test (SUT) which weren't testable by automated test on default (have no Oracle and are ...
0
votes
0answers
36 views

Same name for a view and synonym in same schema

Scenario: In a schema (sc1), there is a synonym with name syn1 for table t1. I created a view with name as sc1.syn1. And it got created successfully without any conflict with synonym. Synonymn (syn1) ...
0
votes
0answers
130 views

MySql view returns a single NULL value for a NOT NULL column, why?

I am working with a database built by a vendor, which I have remote access to. I noticed that the field modify_date on one of the views is not null, according to DBeaver. the tick indicates "not ...
0
votes
1answer
387 views

Direct, simple SQL query results in "ORA-01406: fetched column value was truncated"

All the information I've seen on this issue is always in regards to running a query via some other utility (e.g. TOAD); however, I am seeing this issue when I simply try to select * from v$asm_disk; ...
1
vote
1answer
29 views

Normalize SQL to the same format

I want to write a package that will manage mysql/pgsql views, but for that I need to check if the view defined in the code is the same as the view in the database which I get with show create table ...
2
votes
1answer
842 views

MySQL - Joining table with different charset in a view

I want to join tables from two different schemas. But the problem is both schemas follow different charset utf8_general_ci & utf8mb4_unicode_ci. When i do a join on both tables, it works. But, ...
0
votes
1answer
22 views

Triggers or views on frequently updating table

We have a table which is frequently updating. We have a scheduler to update this table which runs every 10 minutes. There are not more than 50k records in this table but when scheduler runs, database ...
1
vote
1answer
52 views

Is there anything wrong with splitting a complicated view into many small ones?

I have a view where each row is associated with a customer, and the columns are various computed values such as life_time_value and purchases_per_week, as well as more complicated statistical values ...
1
vote
1answer
62 views

Create a key-preserved view across Oracle tables with descending indexes

I'm trying to create an updatable view between two Oracle tables which have exactly the same key structure. The existing tables are created by an ERP system and: Do not have primary keys - only a ...
1
vote
1answer
46 views

Recursive Parent-Child Location Relationship Cache as View

Here is my data structure: CREATE TABLE Locations( LocID int IDENTITY(1,1) NOT NULL, LocationTypeID int NOT NULL, ParentID int NULL, LocNum varchar(50) NULL, LocName varchar(250) ...
1
vote
1answer
34 views

Adding one record from master-table in addition to other records from detail-table to a MySQL-View

I am facing a problem creating a MySQL-View. I am not really a pro and i have no clue how to make this work. The situation is the following: I´ve got a table "Customers" (Master) with all the costumer ...
0
votes
1answer
34 views

views restored from backup in a different server referring to linked servers

I have 3 SQL servers X, Y, Z and 2 databases X.A and Y.B. There are (many) view in X.A that uses 4-level naming in their definition: SELECT ... FROM Y.B.SCHEMA.TABLE From this I infer that X ...
0
votes
1answer
636 views

Full text search with json field in SQLite

Is it possible to have full text search in SQLite along using json? In SQLite json is stored as TEXT (JSON1). Full text search requires creation of virtual table (full text) but I don't know how to ...
-2
votes
1answer
75 views

Oracle Delete From a View [duplicate]

I need to compile below query: delete from dba_audit_trail where TIMESTAMP > SYSDATE - 30;
1
vote
1answer
123 views

MySQL - view select rooms not in booking range

I'm using a select query within a view to find when a room is available, a booking is identified with a reference and a start/end date. view: USE CATTERY2; CREATE VIEW RoomAvalability AS SELECT ...
-1
votes
1answer
498 views

Use a temp table's result in a view [closed]

I am using a temp table in a stored procedure. I need to use that temp table's result in my view. How can I do that?
1
vote
1answer
62 views

Insert into indexed view?

I give an example to show my problem. I create 2 table as the following: CREATE TABLE a ( id INT ) CREATE TABLE b ( name NVARCHAR(10), id INT ) Then insert data into these tables ...
0
votes
2answers
37 views

how to view data as history of field value change

Example i have data like id employeeId Salary Year 1 1 12000 2001 1 2 10000 2001 1 1 16000 2002 1 3 12000 2004 1 ...
0
votes
1answer
161 views

Querying 500 million records in Oracle view takes forever

I really need professionals help now after wasting a week of time to solve my problem and searching on Stack Overflow. I have a view created on top of two different tables. This view has 500 million ...
4
votes
2answers
285 views

Why is the result of a totally deterministic and all-encompassing "case" in select query in view nullable?

I have a table, with Id as the primary key. create table Anything ( Id bigint not null primary key identity(1, 1) ) When I look at this table in Object Explorer, I see this image of course: As ...
1
vote
1answer
42 views

Are there any unforseen down sides to using views to abstract away from cryptic table names?

We have to report against a very large and complex vendors HR/Payroll database which has cryptic table names such as A100M, C755V, X50AA etc. In order to make writing queries more human friendly, I ...
1
vote
1answer
78 views

What is the rationale of dropping all indexes for an altered view in SQL Server?

This is a follow up of ALTER VIEW drops Index from View question. The accepted response indicates that ALTER VIEW will automatically drop any defined indexes. This is somewhat counter intuitive to ...
12
votes
2answers
727 views

ALTER VIEW drops Index from View

as the header line suggests: Using an ALTER VIEW statement on a VIEW that has an index on it will drop this (all?) indexes from the VIEW without warning. I would prefer the ALTER VIEW statement to ...
1
vote
1answer
88 views

Select * from View is taking a SUPER long time [closed]

I have created a view which gets data from 5 tables, 3 of them containing 200k+ rows,340k+ rows and 2.1mill+ rows. The view contains group by clause, case statements and CTEs. When I do a simple ...
1
vote
1answer
174 views

Create a view with distributed Lobs

I have two Oracle 18c instances (instance 1 with schema DB1 and instance 2 with schema DB2) and I know that there ist a support for distributed lobs since 12.2. So i did the following: CREATE TABLE ...
-1
votes
1answer
35 views

How can I select non null columns from a view of EAV tables

I have a VIEW that queries my E-A-V model which uses datatype tables to store the values. I have an entity that contains many attributes, each attribute can be a different datatype. The DataType ...
0
votes
1answer
122 views

Modelling a user-defined filter set in SQL

In my database I have a table containing data that I need to filter. The exact contents of this table aren't important so I'll just call it data. Now, my users also need to be able to create filter ...
1
vote
1answer
2k views

Postgres: How can I force index usage for view with latest rates?

We import currency rates into DB: CREATE TABLE currency_rate ( id int8 NOT NULL, date date NOT NULL, currency varchar(3) NOT NULL, rate numeric(12,6) NOT NULL, CONSTRAINT ...
0
votes
1answer
47 views

Sql Server view with very limited access

I have a requirement to limit a view in Sql Server 2008 R2 that user: user has access to select from view. user has not access to copy the result from select statement. user has not access to join ...
0
votes
1answer
36 views

Order database view in new columns

I've created a view from a table in SQL Server which cannot be altered in any way. The purpose is to make the fairly complex table conceivable for the users. The view consists of several columns ...
0
votes
1answer
28 views

Optimizing the repeated use of the same if condition inside a VIEW?

CREATE OR REPLACE VIEW VIEW_NAME AS ( SELECT table0.fieldBlah "FieldBlah", --more fields IF(table1.foo or table2.foo IN ('State1', 'State2'), 0, table3.uniqueField) "uniqueFieldName") ...
30
votes
4answers
4k views

Does SQL Server Only Perform Calculations In A SELECT List Once?

Take the following example: SELECT <CalculationA> As ColA, <CalculationB> As ColB, <CalculationA> + <CalculationB> As ColC FROM TableA Would CalculationA and ...
1
vote
1answer
40 views

Only join to latest entry in subselect in a given range determined by the main select

I have one table Haul and one table ChargeCarrier_Storage. The latter contains movements of charge carriers between storage locations. Haul has an arrival and a departure time. I want to join together ...
1
vote
1answer
1k views

MYSQL - How to optimize VIEW performance?

Total profiles - 100000 Each profile is connected to one or more platform Each profile have 50 Tags Each profile have 4 themes I have a user view (total users around 100000) where I am joining all ...
0
votes
1answer
53 views

Get notification about invalid views

I have 40 views that are integrated/synced to a work order management system on a weekly basis. The views are based on GIS tables which are notoriously messy. Over time, the views can end up becoming ...
0
votes
0answers
136 views

ORACLE MULTIPLE TABLE INDEXES ON GROUP BY

I have a VIEW with multiple tables, it has a group by statement containing multiple columns from each table. The problem is access to the view takes 4,5 seconds and ideally should take less than 1. ...
2
votes
1answer
94 views

SQL SERVER: Find and Drop Invalid View

I have a SQL Server 2012 database which contains a number of views which have become invalid. The underlying tables the views referenced were migrated to another schema for archiving. What's the best ...
7
votes
3answers
3k views

Manipulating a Column Containing Key/Value Pairs

I'm accessing and creating reports from a vendor via a replicated SQL Server database. They've done some absolutely insane things that I've been trying to solve for, but this one takes the cake. ...
1
vote
1answer
61 views

Creating a view that calculates percentages

I have this table getting populated with top10 destination ports every ten minutes along with a "total" entry that records the total number of bytes and packets transmitted for each port for the time ...
0
votes
1answer
61 views

split big table into two joined view

i have a big postgres db with single table for product and attribute but i want two view of one with product and one with attribute. for example now i have tb_products iditem | name | attributes ---...
2
votes
1answer
42 views

Creating a view (or table) from JSON data with two different shapes

I'm pulling in JSON data from two different sources that have roughly the same information, but in different shapes. Let's say I'm pulling in data about music albums, and one of the API responses ...
1
vote
2answers
74 views

Improving the queries in a view to query custom types

I'll spare you the details, but I've got a situation where I'm going to be creating and managing a lot of custom types. (Postgres 11.4, ultimate deployment under RDS.) It looks like there isn't a ...
-1
votes
1answer
65 views

How to create a VIEW when Table1 is having relation to Table2 on several of it's fields?

My situation (greatly simplified) is as follows: Table1 ID Name Ver1 Ver2 Ver3 Ver4 Table2 ID Name ... This table holds the versions The columns Ver1 - Ver4 are foreign keys and are IDs of ...
0
votes
1answer
71 views

Optimize a postgresql database view query

Given the following database schema (using rails-like associations, as this is a ruby-on-rails project, also please forgive me for how I phrase this for I am new to this forum): Client has_many Deals ...
0
votes
1answer
2k views

Entity Framework 6: How can I add new column to existing table and at the same time update view (add column) in same migration file [closed]

Example in the EF6 migration file Up method. I wish to add a new column B in existing table Country. Sql("ALTER TABLE [dbo].[Country] ADD [B] INT DEFAULT((0)) NOT NULL;") Then I will need to ...
1
vote
1answer
31 views

SQL Server 2016 - Disparity Between View Definition and View Design

I've run into an interesting issue with some databases I've inherited, and could use some help unpacking it all. The Issue After adding a column to a table, views selecting * from that table are now ...

1
2
3 4 5
13