Questions tagged [default-value]

For questions relating to DBMS-supplied values that are generated when none are explicitly provided.

13 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2 votes
0 answers
76 views

Default roles ticked when creating new login through SSMS GUI

When creating a new login via the GUI: In the User Mapping section, certain databases will have some roles pre-ticked in the Database Role Membership section. What controls this behavior? It's ...
soapy smith's user avatar
2 votes
0 answers
3k views

Something similar to GENERATED ALWAYS for a DEFAULT? (SQL Server / Azure SQL)

Question: Is there any way to force a column to always use the default value definition? I would like to always have the user_id populated on an insert/update (I know delete might be a bit different) ...
Brian Jorden's user avatar
1 vote
1 answer
3k views

How can I create a unique and random alphanumeric string using MySQL's Default Value? (v 5.6)

I am building a MySQL database and think using implicit DEFAULTS seems very promising. I am successfully using DEFAULT CURRENT_TIMESTAMP and DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP for ...
LWSChad's user avatar
  • 111
1 vote
0 answers
80 views

How to save SSMS 2012 Object Explorer Scripting Settings?

I'm generating a bunch of object creation scripts in SSMS 2012, using the Object Explorer context menu. The default options for these generated scripts are not to my liking (for example, I want the ...
Rebeccah's user avatar
  • 141
1 vote
0 answers
119 views

How to pass the value of PK to FK

Ok, so here it goes. I have a table called employee. then I have another table called languages. I need to copy the value of PK of employee table to foreign key in Languages table, rather than ...
theo's user avatar
  • 31
1 vote
0 answers
44 views

Uninitialized values: ignore or set?

From the implementation point of view for a database, is it preferable to handle optional form fields by setting to some default value (e.g. false, 0, "", etc.) or just ignore such fields (do nothing ...
Stumbler's user avatar
  • 123
0 votes
0 answers
193 views

How to specify default CREATE TABLE values just once?

Is there any way I can just say once that the default type should be TEXT, and the default value should be '' for all CREATE TABLEs? Currently I must do: CREATE TABLE "t" (dbm TEXT DEFAULT ''...
Dan Jacobson's user avatar
0 votes
2 answers
61 views

Conditionally use computed column

IS it possible that a not nullable column can be setup to either a) add value freely with INSERT/UPDATE query b) if value not provided on insert, to avoid null entry added default the value to that of ...
Sami.C's user avatar
  • 153
0 votes
0 answers
12 views

change db column default from NULL to <null>

When inserting rows in table, a default value is a NULL. Is their a way to make "<null>" such that, +--------------+-------------+------+-----+-------------------+----------------+ | Field ...
nish's user avatar
  • 101
0 votes
2 answers
745 views

Insert records from one table to other with default serial

I have two tables with same structure, first column gid as serial, and many other columns after that. I want to insert selected rows from one table to the other. Without serial it is really easy: ...
Miro's user avatar
  • 101
0 votes
1 answer
306 views

What is the default column name given to a TABLE() type with a single column

CREATE OR REPLACE TYPE MISSING_KEYS AS TABLE OF VARCHAR2(256); SELECT [¿what goes here?] as missing_key FROM TABLE (MISSING_KEYS('A','B','C','D')) What is the default column name that should be in [¿...
user avatar
0 votes
0 answers
455 views

DROP DEFAULT on psql restore fails because column not existing anymore

A dump creates a command to remove default values like: ALTER TABLE IF EXISTS test.simulation ALTER COLUMN gid DROP DEFAULT; When on restore the column with the default value do not exist anymore, ...
signedav's user avatar
  • 131
0 votes
1 answer
50 views

Assign value to a field after checking a condition

I have this query: ALTER TABLE MERCHANTS ADD COLUMN merchant_image bytea, ADD COLUMN merchant_logo bytea, ADD COLUMN merchant_address VARCHAR(100), ADD COLUMN merchant_phone VARCHAR(50), ...
fishera's user avatar
  • 101