Skip to content

Grant on dynamic database name in Postgresql

I am trying to grant a new user permissions on the current database (whose name I do not know). Basically I want to archive something like this: Any hints how this could be achieved? Answer You cannot combine GRANTs with queries directly, but you may write a small block to achieve that. Since GRANT allows onl…

Cannot insert the value NULL into column ‘ExampleID’

Upon executing I keep receiving the error: Cannot insert the value NULL into column ‘ExampleID’, table ‘DB_Example.dbo.tbl_Example’; column does not allow nulls. INSERT fails. However I don’t think any NULL values are present. I am trying to simply fill a table with specific valu…

How to add a column in MSSQL with default value?

In MSSQL 2014 I would like to use an update syntax which is adding a new column with a default value. Is this possible somehow? Answer Here is a complete reproducible example. Create table Check contents Add new column with default value Check the result Here is a SQL fiddle with this example.

PostgreSQL conditional ENUM

Let’s say I have a table inventory with columns item_id, category and size. item_id is auto incremented integer (primary key) category is ENUM size is ENUM I want size to be a conditional ENUM. …