Questions tagged [default-value]
For questions relating to DBMS-supplied values that are generated when none are explicitly provided.
91 questions
1
vote
2
answers
233
views
Use column default value for optional parameter in stored procedure
What I'm trying to do is to have an optional parameter in my stored procedure that gets the default value defined in the table if not provided.
create table primates (
id int identity(1,1) ...
0
votes
0
answers
762
views
In Snowflake, default value NULL on a not-nullable column?
In Snowflake, what are the implications of having a default value of null on a non-nullable column?
Also, when I describe a particular table in Snowflake, I see a default value of NULL in all columns. ...
0
votes
1
answer
138
views
Are default values for a column still required if using audit triggers?
I have a couple of audit columns in my table:
modified_by
modified_date
I have an AFTER trigger set up to automatically update these columns whenever data is inserted or modified, with current_user ...
1
vote
1
answer
44
views
Can an existing blank field be changed to that it defaults to Y, but can only be changed to N
I am a complete novice, I hope my terminology is correct.
I have a database created long ago. It helps keep track of visitors.
The visitor’s data is entered manually, but some fields are calculated ...
1
vote
4
answers
6k
views
Change the default value of a string column to real uuid()
When I use show create table Posts I see this column:
`Slug` varchar(400) NOT NULL DEFAULT 'uuid()'
This means that the default value is a string. I want the default string to be a real uuid() ...
0
votes
1
answer
74
views
What is the suggested value for guardrail fields_per_udt_warn_threshold?
Cassandra has added guardrails feature some time ago, bust none of the guardrails have any default value set in the configuration file (see cassandra.yaml). I generally wonder how can a db admin know ...
1
vote
1
answer
744
views
Set a column value using the (remote) default when inserting a row into a foreign table
I have a database with a table whose primary key is a serial column, or a column with a locally-computed default value that prevents conflicts, for instance:
CREATE TABLE foo (
foo_id serial ...
0
votes
1
answer
275
views
MYSQL: Return a predefined value if result of join is null
Before all, sorry my very bad english level.
Here's my problem.
If i have two tables:
'Products'
|id | product |
|---|---------|
|1 | "Fork" |
|2 | "Spoon" |
|3 | "Knife&...
4
votes
2
answers
6k
views
Inserting dummy data into an empty table having a primary key integer field GENERATED ALWAYS AS IDENTITY
I'm trying to generate dummy tables with dummy data for testing performance with some SQL tasks.
Based on this old thread: Is there a way to insert multiple rows into a table with default values for ...
7
votes
1
answer
20k
views
Is it safe to use default value with not null when adding a new column?
We have a Rails app powered by Postgresql v11.4 where I want to add a new column with a default value and a not null constraint like below:
ALTER TABLE "blogs" ADD "published" ...
2
votes
0
answers
97
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 ...
3
votes
1
answer
11k
views
Use default value instead of inserted null
I have a table definition in Postgres that use now() for timestamp and current_user() for auditing.
date_created date NULL DEFAULT now(),
edited_by varchar NULL DEFAULT "current_user"(),
...
0
votes
0
answers
238
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 ''...
0
votes
1
answer
5k
views
MySQL 8.0 timestamp CURRENT_TIMESTAMP sets date to '0000-00-00 00:00:00' (was ok in 5.7)
The table T has this field
+---------------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra ...
0
votes
1
answer
531
views
How to create a trigger that generate a random specific output to insert into a table in MariaDB?
I have an account table which is laid out in 3NF:
CREATE TABLE account (
account_id INT AUTO_INCREMENT,
customer_id INT NOT NULL,
account_type_id VARCHAR(15) NOT NULL,
is_active ...