sql-view

Cannot update view?

岁酱吖の 提交于 2019-12-17 16:37:42
问题 My site was developed using Drupal 6 running on a Postgresql 8.3 server on Ubuntu 11.10. Also webmin version 1.590. Now I want to update records in a table, but when I run: UPDATE uac_institution_view SET status = '2' WHERE nid = '9950' it gives me an error like: Failed to execute SQL : SQL UPDATE uac_institution_view SET status = '2' WHERE nid = '9950' failed : ERROR: cannot update a view HINT: You need an unconditional ON UPDATE DO INSTEAD rule. The problem is that only SELECT queries work.

Computed / calculated / virtual / derived columns in PostgreSQL

北慕城南 提交于 2019-12-16 19:55:31
问题 Does PostgreSQL support computed / calculated columns, like MS SQL Server? I can't find anything in the docs, but as this feature is included in many other DBMSs I thought I might be missing something. Eg: http://msdn.microsoft.com/en-us/library/ms191250.aspx 回答1: Up to Postgres 11 generated columns are not supported - as defined in the SQL standard and implemented by some RDBMS including DB2, MySQL and Oracle. Nor the similar "computed columns" of SQL Server. STORED generated columns are

Can I concatenate a virtual column in a view?

≡放荡痞女 提交于 2019-12-12 18:27:55
问题 Unfortunately, I have plaintext passwords in a database. I want to pass these plaintext values around as little as possible for, say, comparisons and updates. To this end, I'm trying to create a view of my Users table that excludes the plaintext passwords and instead provides a hashed value of that password. Here's my current SQL Server view, which doesn't work: SELECT CAST(CAST(32768 * RAND() AS INT) AS NVARCHAR) AS PasswordSalt HashBytes('SHA1', PasswordSalt + u.Password) AS PasswordHash

Create view with primary key?

佐手、 提交于 2019-12-12 09:29:18
问题 I create a view with following codes SELECT CONVERT(NVARCHAR, YEAR(okuma_tarihi)) + 'T1' AS sno, YEAR(okuma_tarihi) AS Yillar, SUM(toplam_kullanim_T1) AS TotalUsageValue, 'T1' AS UsageType FROM TblSayacOkumalari GROUP BY CONVERT(NVARCHAR, YEAR(okuma_tarihi)) + 'T1', YEAR(okuma_tarihi) UNION ALL SELECT CONVERT(NVARCHAR, YEAR(okuma_tarihi)) + 'T2' AS sno, YEAR(okuma_tarihi) AS Yillar, SUM(toplam_kullanim_T2) AS TotalUsageValue, 'T2' AS UsageType FROM TblSayacOkumalari GROUP BY CONVERT(NVARCHAR,

Creating View from Related Child Tables

自闭症网瘾萝莉.ら 提交于 2019-12-11 12:35:23
问题 I have the following general table structure (forgive the United States-centric carmakers in my contrived example): CREATE TABLE Car ( [Id] int PRIMARY KEY ) CREATE TABLE Ford ( [FordId] int PRIMARY KEY, --also a foreign key on Car [Model] nvarchar(max) ) CREATE TABLE Chevy ( [ChevyId] int PRIMARY KEY, --also a foreign key on Car [Model] nvarchar(max) ) I am wanting to create a view on top of these tables so that I can retrieve all Fords and Chevys and just have a generated column in the view

Materialized views with MySQL

北战南征 提交于 2019-12-11 09:12:22
问题 Emulated materialized views with MySQL has good performance? I'm learning how to do with this link thanks Correction: "Materialized views" to "Emulated materialized views". 回答1: MySQL doesn't have materialized views - the link just creates a table and stuffs data into it so the table can be indexed. That means the performance is par with a normal table, but you also have the overhead of flushing & repopulating the table (including indexes). I didn't see what engine the table was using, but

“ERROR: column … specified more than once” in VIEW definition

前提是你 提交于 2019-12-11 05:14:07
问题 This is a follow-up question to an earlier one. I have a stored function f1 that takes two arguments returns a table with 5 columns; for now the returned values are constant, later they will be calculated from the arguments. I also have a table t1 with two columns that correspond in type to f1 's arguments. I would now like to define a view v1 that contains the union of all rows returned from f1 for all argument pairs stored in t1 . For the given example values the result should be: +---+---+

How do I port query with GROUP BY clause to PostgreSQL?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 00:35:02
问题 I'm porting a simple expense database to Postgres and got stuck on a view using GROUP BY and multiple JOIN clauses. I think Postgres wants me to use all the tables in the GROUP BY clause. Table definition is at the end. Note that columns account_id , receiving_account_id and place may be NULL and an operation can have 0 tags. Original CREATE statement CREATE VIEW details AS SELECT op.id, op.name, c.name, CASE --amountsign WHEN op.receiving_account_id IS NOT NULL THEN CASE WHEN op.account_id

Error: Could not use view or function because of binding errors

拜拜、爱过 提交于 2019-12-10 00:50:44
问题 I got read only access to Views and when i am trying to query the View i got this error message. Can anyone help me understand what is the actual problem and how to fix it. FYI.. this is the 1st time i am viewing this table . Here is the error message. Msg 207, Level 16, State 1, Line 1 Invalid column name 'ProductCategoryL2Name'. Could not use view or function 'DB.Product' because of binding errors. 回答1: It sounds like the view was created and then one of the underlying tables was changed. I

How much space does a view take up in Microsoft SQL Server

笑着哭i 提交于 2019-12-08 16:23:06
问题 I have a very large table in SQL Server 2008. It has lots of fields which are only useful to a certain segment of users, some of the fields some users shouldn't be able to see. The table is huge so I wanted to create some simple views for each user class where I could give them access to the view and they could only see the columns they need. Does a view take up space in the database, or would it be saved as a simple select statement? 回答1: Unless the view is indexed, it takes up almost no