How to create Editioning View in snowflake? - snowflake-cloud-data-platform

I am trying to convert a ddl for a oracle view to snowflake view. But in Oracle ddl the view created is of FORCE EDITIONING type. But these keywords are not supported by snowflake. Can anyone share the ideas to replicate the same ?
Thanks

Oracle 11g Release 2 introduced "Editions" so people could upgrade an application's database objects while the application is in use, and then essentially flip a switch after all modifications were complete and users could then begin running all of their commands on the new "edition" or "release" of their objects.
Snowflake doesn't have this capability (yet), so you'll need to omit that clause from your Create View command.
Here are the docs on creating a view in Snowflake.
https://docs.snowflake.com/en/sql-reference/sql/create-view.html
I hope this helps...Rich

Related

Enterprise Architect Compare database

I am very new to EA and in general data engineering. I want to be able syncronize my MS SQL DB with the data model I created in EA. Using the help and tutorials, I learnt how to push my data model onto the MS SQL DB. What I fail to achieve is the syncronization. I have a feeling that is has to do with the schema. The database builder lists all the orginal tables and then again all tables from the ODBC connection with an additional 'dbo.'
Do i need to define this somwhere in the options of my data model or can I compare the data model with the server taking account of the schema?
You need to work in the “Database Builder” feature of Sparx EA.
This can be found on the "Develop" tab. (This will not work directly from the “Browser”)
Select the package having the “Database” as its stereotype. Use mouse button 2 and select “Manage DBMS Options”. The dialog will enable you to change the table(s) owner or even change the selected DBMS type. From the database builder you can then perform the "database compare" or "compare with options".
Note regarding terminology - the "dbo" in SQL Server is a the database owner.
(I have also posted this answer to the Sparx Forum.)
You can find the related documentation with screen images here: https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/model_domains/import_schema_into_builder.html
I needed to add the owner tag dbo to all my tables. For some reson it was not enough to add it to the data model object. Thanks to this thread i found an option to change it for all tables at once.
How do you set the database schema, at the package level, in SPARX Enterprise Architect?
There were still some differences about the PK and FK ids when i tried to compare but I just aligned my local data model with that and now there are no differences between the data model and the data base.

Group tables by schema in SSMS

In Visual Studio's Server Explorer window there's a very nice feature that lets you see the DB objects grouped by schema:
It turns this object tree:
Data Connections -> MyServer -> Tables -> MyTable (MySchema)
Into this one:
Data Connections -> MyServer -> Schemas -> MySchema -> MyTable
I've been looking for this particular feature in SSMS but was unable to find it.
Does it exist?
If not, is there a plugin which would provide this feature?
Or perhaps is there a plugin which would help ease navigation in DBs which have lots of objects?
Please note I'm aware of SSMS object filters. It's better than nothing but not sufficient, as I'm often accessing objects from multiple schemas at once.
If you want a free tool, SSMS Schema Folders (GitHub repo) is your solution. It does the job beautifully.
I love the idea of grouping by schema.
SQL Treeo SSMS Addin is an inexpensive tool that allows you to create your own table structure in the Object Explorer.
You can try as follows in SSMS:
Tables > Filter > Filter Settings
There you are able to filter by schema...

Create copy of a database only schema

I am relativley new to MS SQL server. I need to create a test database from exisitng test data base with same schema and get the data from production and fill the newly created empty database. For this I was using generate scripts in SSMS. But now I need to do it on regular basis in a job. Please guide me how I can create empty databases automatically at a point of time.
You will have a very hard time automating the generate scripts wizard. I would suggest using something like Red-Gate's SQL Compare (or any alternative that supports command-line). You can create a new, empty database, then script a compare/deploy using the command line from SQL Server Agent.
Another, more icky alternative, is to deploy your schema and modules to the model database. You can keep this in sync using SQL Compare (or alternatives), or just be diligent about deployment of schema/module changes, then when you create a new database it will automatically inherit the current state of your schema/modules. The problem with this approach (other than depending on you keeping model in sync) is that all new databases will inherit this schema, since there currently is no way to have multiple models.
Have you considered restoring backups?
To add to Aaron's already good answer, I've been using SQLDelta for years - I think it's excellent.
(I have no connection to SqlDelta, other than being a very satisfied customer)

Can Linq to Sql (L2S) update a database when a class/property is added to the DBML?

I have a small L2S database that was generated with the L2S CreateDatabase command. When I add a class or property to the DBML, the database is not updated automatically. I get errors like "Table not found" at runtime.
Is there a way to add new tables and columns to a database?
No, LINQ to SQL cannot update your database schema to reflect changes made to DBML. To do so you'll have to either recreate your DB from scratch (which, granted, LINQ to SQL does not do very well), or use something like Wizardby to version and upgrade your DB schema.
No it is not. You need to refresh your Server Explorer, and then remove your changed table form DBML, then drag and drop it and CTRL + S :}
Not out of the box, but there are third party tools that add that kind of functionality. Take a look at my tools - Huagati DBML/EDMX Tools.
The add-in can generate the change scripts for you, and there is also a runtime component that can be used within your app to detect and generate SQL-DDL for diffs between the model and the database.

How to partially migrate a database to a new system over time?

We are in the process of a multi-year project where we're building a new system and a new database to eventually replace the old system and database. The users are using the new and old systems as we're changing them.
The problem we keep running into is when an object in one system is dependent on an object in the other system. We've been using views, but have run into a limitation with one of the technologies (Entity Framework) and are considering other options.
The other option we're looking at right now is replication. My boss isn't excited about the extra maintenance that would cause. So, what other options are there for getting dependent data into the database that needs it?
Update:
The technologies we're using are SQL Server 2008 and Entity Framework. Both databases are within the same sql server instance so linked servers shouldn't be necessary.
The limitation we're facing with Entity Framework is we can't seem to create the relationships between the table-based-entities and the view-based-entities. No relationship can exist in the database between a view and a table, as far as I know, so the edmx diagram can't infer it. And I cannot seem to create the relationship manually without getting errors. It thinks all columns in the view are keys.
If I leave it that way I get an error like this for each column in the view:
Association End key property [...] is
not mapped.
If I try to change the "Entity Key" property to false on the columns that are not the key I get this error:
All the key properties of the
EntitySet [...] must be mapped to all
the key properties [...] of table
viewName.
According to this forum post it sounds like a limitation of the Entity Framework.
Update #2
I should also mention the main limitation of the Entity Framework is that it only supports one database at a time. So we need the old data to appear to be in the new database for the Entity Framework to see it. We only need read access of the old system data in the new system.
You can use linked server queries to leave the data where it is, but connect to it from the other db.
Depending on how up-to-date the data in each db needs to be & if one data source can remain read-only you can:
Use the Database Copy Wizard to create an SSIS package
that you can run periodically as a SQL Agent Task
Use snapshot replication
Create a custom BCP in/out process
to get the data to the other db
Use transactional replication, which
can be near-realtime.
If data needs to be read-write in both database then you can use:
transactional replication with
update subscriptions
merge replication
As you go down the list the amount of work involved in maintaining the solution increases. Using linked server queries will work best if its the right fit for what you're trying to achieve.
EDIT: If they're the same server then as suggested by another user you should be able to access the table with servername.databasename.schema.tablename Looks like it's an entity-framework issues & not a db issue.
I don't know about EntityToSql but I know in LinqToSql you can connect to multiple databases/servers in one .dbml if you prefix the tables with:
ServerName.DatabaseName.SchemaName.TableName
MyServer.MyOldDatabase.dbo.Customers
I have been able to click on a table in the .dbml and copy and paste it into the .dbml of the alternate project prefix the name and set up the relationships and it works... like I said this was in LinqToSql, though have not tried it with EntityToSql. I would give it shot before you go though all the work of replication and such.
If Linq-to-Entities cannot cross DB's then Replication or something that emulates it is the only thing that will work.
For performance purposes you probably want either Merge replication or Transactional with queued (not immediate) updating.
Thanks for the responses. We're going to try adding triggers to the old database tables to insert/update/delete records in the new tables of the new database. This way we can continue to use Entity Framework and also do any data transformations we need.
Once the UI functions move over to the new system for a particular feature, we'll remove the table from the old database and add a view to the old database with the same name that points to the new database table for backwards compatibility.
One thing that I realized needs to happen before we can do this is we have to search all our code and sql for ##Identity and replace it with scope_identity() so the triggers don't mess up the Ids in the old system.

Resources