I have a scenario wherein I have to convert transient snowflake table to permanent table and also have same grants and data share. Is there any way to do it?
Not directly, you can either follow a similar approach as explained here:
https://community.snowflake.com/s/article/Change-permanent-table-to-transient-table
or maybe something like this:
CREATE OR REPLACE TABLE permanent_table CLONE transient_table;
Related
I would like to create tables from existing tables without copying the data to the new tables in snowflake. Is this possible?
For example:
I have tables say "DB"."SCHEMA"."tb1" and "DB"."SCHEMA"."tb2".
I would like to create tables "DB"."SCHEMA"."tb3" and "DB"."SCHEMA"."tb4" from "DB"."SCHEMA"."tb1" and "DB"."SCHEMA"."tb2" without copying their data to "DB"."SCHEMA"."tb3" and "DB"."SCHEMA"."tb4".
Kindly help.
Thanks in advance.
The answer for above question is as below:
CREATE TABLE "DB"."SCHEMA"."tb3" LIKE "DB"."SCHEMA"."tb1"
CREATE TABLE "DB"."SCHEMA"."tb4" LIKE "DB"."SCHEMA"."tb2"
As rightly mentioned, "LIKE" operator when used with "create table" would create a table from parent without copying the data.
Here is the documentation for this command and example : https://docs.snowflake.com/en/sql-reference/sql/create-table.html
I am able to DROP and CREATE a temporary table but when I do a select, it doesn't recognize the object. I know it's there but how can I access it?
FYI, I have multiple databases in SQL Server (2008). I tried the below but it doesn't work.
SELECT *
FROM tempdb..#TBL_IMPORT
Usually to access tables I have to type this: dbname.dbo.tablename
Any clue? Thank you.
With the amount of information given, the answer is in the comments.
If you would like to query a temp table from a second session, you'll need to create the temp table as a global temp table.
select *
into ##MyGlobalTable
from SourceTable
If you're using SSMS you will want to use the same window you create the temp table in if not using a global temp table. If you're using a secondary application you'll want to validate you're using the same SPID.
Other approaches you may be interested in would include CTEs (common table expressions) and variable tables. Google will have a wide assortment of assistance, or you could update your question here.
In my database there are a table that is declared like MC something like this
CREATE TABLE [MC].[tb_products]()
What is it for? Or what is?
[MC] is a database schema. Advantages to using it are logical grouping and being able to control permissions.
See: What is purpose of database schema?
We need to keep in database following information about database:
Name;
Author;
Short decription;
I can just use special table for it (id, name_property, content). But maybe there is some nice tricks for it?
If you want to store information in a database, use a table. That's what they are for.
EDIT:
SQLite has no notion of documenting a table. A table's creator and textual description are simply not things implemented in SQLite. Sorry. Your best bet would be a table on its own that carries that information.
I have 2 database call CUSTOMER_NEW and CUSTOMER_OLD.
I want to use on table that is cust_info's design in CUSTOMER_NEW table without recreating all the field again.
And I want to do this by any method other than writing a code of using that table in that new database..
select * into customer_new.newtable from customer_old.originaltable