I went through the Snowflake docs and found that the default date_output_format in snowflake is "YYYY-MM-DD".
We can change it to per session as (alter session set date_output_format = 'DD-MON-YYYY').
But I want to change the default value irrespective of the session. So that whenever I open the snowflake and query the date should be in the format "DD-MON-YYYY".
Can anyone please help me, if it's possible to do so?
Depending on needs DATE_OUTPUT_FORMAT could be set up on ACCOUNT/USER level:
ALTER ACCOUNT SET date_output_format = 'DD-MON-YYYY';
ALTER USER <user_name> SET date_output_format = 'DD-MON-YYYY';
Related: Parameter Hierarchy and Types
Related
Is the only way to explicitly add a column with default value current_timestamp()? or can we use snowflake change data capture feature: streams, changes, etc.
Snowflake does not have triggers, which is how update times are done in PostgreSQL for example. And it does not have built update times, so explicit is your only option, but luckily it's not that hard.
In snowflake you can have columns with default values
CREATE or replace table tempdw.sample_insert_time
(
name varchar,
insert_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
insert into tempdw.sample_insert_time (name)values('john_doe');
select * from tempdw.sample_insert_time;
NAME INSERT_TIME
john_doe 2020-07-14 21:23:22.392
Let me know if this helps.
Snowflake doesn't have triggers, but you can emulate their behaviour using streams and tasks, and I have a feeling that's what you're looking for:
https://visualbi.com/blogs/snowflake/change-data-capture-cdc-using-streams-tasks-snowflake/
While creating the database by using the create database statement in informix, I couldn't enable is_nls parameter in sysdatabases table in sysmaster database.
How to enable it?
The is_nls column on the sysdatabases view over the sysmaster is a flag that tells whether GLS is enabled (1) or not (0).
You should not try to change it over this view nor the sysdbspartn table.
If what you're trying to do is change the code set used for a database that it's not possible.
To specify a code set on the creation you must set environment variable DB_LOCALE for the one you want.
You can check the locale in which the database was created by querying the sysmaster view sysdbslocale.
I have a 12 years old mdb database and I was asked to add a new column to a table and set to a default value of "1".
My knowledge of asp/mdb is close to zero. I also have no Access or similar softwares.
I tried with:
ALTER TABLE Members ADD COLUMN Privacy Double Default 1
but generates error:
Error: An action query cannot be used as a row source.
Then I tried with:
ALTER TABLE Members MODIFY COLUMN Privacy VARCHAR(4) NOT NULL DEFAULT 'Yes';
but this also triggers another error:
Microsoft JET Database Engine error '80040e14'
How can I set an existing column to a default value?
Should I use an offline tool? If so which one?
Note: I also used an online tool to create the new column but it has no option to set a default value.
So I can either create the new column with the tool and set a default value with SQL, or do the creation of the column with the default value still with SQL.
I solved using AxBase from SourceForge.net.
I could properly open the *.mdb database and run the above SQL commands and they worked perfectly:
ALTER TABLE Members ALTER COLUMN Privacy SET DEFAULT 1
hi your access database is may be in office 2003 or office xp.
You can try to enable sql syntax and then try to run your query.
Tools -> Options -> Tables/Queries -> (At the bottom right:) Sql Server Compatible Syntax - turn option on for this database.
ALTER TABLE Members ADD COLUMN Privacy number Default 1
If you want to set the dateformat to some style say, ddMMyyyy, in sql server we can use the following statement:
SET DATEFORMAT dmy
My question is how to know before hand that this is the format set?
The program I am writing needs to determine, if the above is the actual datetimeformat, else set it and continue with rest of execution.
How is this possible? Else is my only approach, to set it to my desired format and continue with execution?
I hope setting this won't affect other sessions (connections)?
To check the date format use
DBCC useroptions
SET DATEFORMAT will only effect the current session
MSDN Link
the below code, get the current session dateformat, sets it and test if it is working
-- get the current session date_format
select date_format
from sys.dm_exec_sessions
where session_id = ##spid
-- set the dateformat for the current session
set dateformat ymd
-- this should work
select cast('2017-08-13 16:31:31' as datetime)
Starting with SQL 2008, the current date format setting can be determined by SPID/session_id within the dm_exec_requests dynamic management view:
SELECT r.date_format
FROM master.sys.dm_exec_requests r
WHERE r.session_id = ##SPID;
Permissions:
If the user has VIEW SERVER STATE permission on the server, the user is able to see all executing sessions on the instance of SQL Server; otherwise, the user will see only the current session.
It seems there is not a global ## variable to display DATEFORMAT. (?)
The list of ## variables is documented here:
https://learn.microsoft.com/en-us/sql/t-sql/functions/configuration-functions-transact-sql?redirectedfrom=MSDN&view=sql-server-ver15
As per other answers here,
Can use:
DBCC useroptions
and
select date_format
from sys.dm_exec_sessions
where session_id = ##spid
You should convert datetime to desirable format by convert function,
Try this:
SELECT convert(varchar(10),getdate(),103)
OR
SELECT replace(convert(varchar(10),getdate(),103),'/','')
yo can get more information on:
http://msdn.microsoft.com/en-us/library/ms187928.aspx
How to change Oracle 9i database timezone,
I have a user schema with name 'HR_NU', its timezone is -07:00, I want to change it using alter query
alter database set time_zone='+05:00';
but getting errors
Error starting at line 10 in command:
alter database set time_zone='+05:00'
Error report:
SQL Error: ORA-02231: missing or invalid option to ALTER DATABASE
02231. 00000 - "missing or invalid option to ALTER DATABASE"
*Cause: An option other than ADD, DROP, RENAME, ARCHIVELOG, NOARCHIVELOG,
MOUNT, DISMOUNT, OPEN, or CLOSE is specified in the statement.
*Action: Specify only legal options.
I google same issue, and came to know that if I have a table containing a field of datatype timestamp with localtimezone then I will get above error, the solution suggested is change datatype of each column having datatype timestamp, but I have more than 300 tables, and about 200 columns of timestamp datatype.
Any help please.
[SET TIME_ZONE [time_zone_region]]
can be also achieved like this " set time_zone = 'America/New_York' "
have you tried that?