Rename Schema having virtual tables in SAP HANA - hana

I am facing the below error while renaming the schema in HANA2,
SAP DBTech JDBC: [7]: feature not supported: Cannot rename virtual table VT_EMP_EMPLOYMENT_INFO
It is successfully renamed if the schema is not having virtual tables,
The above issue is coming only when there are virtual tables in Schema, Below is the SQL script I'm using
RENAME SCHEMA "MYSCHEMA" TO "RENAMESCHEMA"
Can anyone help me on this?

Renaming virtual tables (and thus renaming a schema that includes virtual tables) is apparently not supported.
I haven't found any documentation about this, but the behavior is what's present with the current HANA Express Edition 2 SPS 04.
The only option I see to effectively rename the schema including virtual tables is to use the export/import method with RENAME SCHEMA option.

Related

Custom Name for `information_schema` database

Is there a way to modify the SQL server to give the virtual information_schema database a different name by default?
Or is information_schema a standard so that software knows where to look and query for information?
I'm using 10.5.15-MariaDB - MariaDB Server
I'd like to rename it to .information_schema so that the database doesn't show up in the middle of the databases list on my CMS.
I don't have control over hiding/displaying databases by name.
information_schema cannot be modified or deleted.
If I were you, I would avoid any attempt to modify the default databases.
Here is what I found searching similar questions:
INFORMATION_SCHEMA is a database within each MySQL instance, the place
that stores information about all the other databases that the MySQL
server maintains. The INFORMATION_SCHEMA database contains several
read-only tables. They are actually views, not base tables, so there
are no files associated with them, and you cannot set triggers on
them. Also, there is no database directory with that name.
*(source)

How to rename a database in azure databricks?

I am trying to rename a database in azure databricks but I am getting the following error:
no viable alternative at input 'ALTER DATABASE inventory
Below is code:
%sql
use inventory;
ALTER DATABASE inventory MODIFY NAME = new_inventory;
Please explain what is meant by this error "no viable alternative at input 'ALTER DATABASE inventory"
and how can I solve it
It's not possible to rename database on Databricks. If you go to the documentation, then you will see that you can only set DBPROPERTIES.
If you really need to rename database, then you have 2 choices:
if you have unmanaged tables (not created via saveAsTable, etc.), then you can produce SQL using SHOW CREATE TABLE, drop your database (be careful anyway), and recreate all tables from saved SQL
if you have managed tables, then the solution would be to create new database, and either use CLONE (only for Delta tables), or CREATE TABLE ... AS SELECT for other file types, and after that drop your database
Alex Ott's answer, to use Clone, is OK if you do not need to maintain the versioning history of your database when you rename it.
However if you wish to time travel on the database of Delta tables after the renaming, this solution works:
Create your new database, specifying its location
Move the file system from the old location to the new location
For each table on the old database, create a table on the new database, based on the location (my code relies on the standard file structure of {database name}/{table name} being observed). No need to specify schema as it's just taken from the files in place
Drop old database
You will then be left with a database with your new name, that has all of the data and all of the history of your old database, i.e. a renamed database of Delta tables.
Pyspark method (on databricks, with "spark" and "dbutils" already defined by default) :
def rename_db(original_db_name, original_db_location, new_db_name, new_db_location):
spark.sql(f"create database if not exists {new_db_name} location '{new_db_location}'")
dbutils.fs.mv(original_db_location,new_db_location,True)
for table in list(map(lambda x: x.tableName, spark.sql(f"SHOW TABLES FROM {original_db_name}").select("tableName").collect())):
spark.sql(f"create table {new_db_name}.{table} location '{new_db_location}/{table}'")
spark.sql(f"drop database {original_db_name} cascade")
return spark.sql(f"SHOW TABLES FROM {new_db_name}")

HSQLDB - Move tables across schemas

Is there a way to move a table from a certain schema to another one?
Just for organizational purposes.
There is no SQL statement for this in versions up to 2.4.1. However, it is possible to edit the .script file of the database and change the schema in the SQL statements.

Location of Liquibase DATABASECHANGELOG Tables

I've seen how to rename the DATABASECHANGELOG tables but what I'm looking to do is to have them created in one database for each server and then deploy to the other databases on that server. We are using Liquibase on MSSQL and Sybase databases and executing via command line.
Thoughts?
I've had the same thought before as well. That's just not how it's done at my current shop :)
You're looking for these options:
--liquibaseCatalogName=<name> The name of the catalog with the
liquibase tables
--liquibaseSchemaName=<name> The name of the schema with the
liquibase tables
Doc here: http://www.liquibase.org/documentation/command_line.html.
However, --liquibaseCatalogName is not documented, but it does appear as an option when checking the command line options via liquibase --help. In your case, I believe "Catalog" equates to a Database in MSSQL and Sybase.

How to rename System Tables Name in SQL-Server_2014?

Can we change System Table names in sql server? If yes then guide me how to do that.
Also, how can I unmark system table? i.e. can I move a table from system tables to user-defined table?
In my experience, Table SQL Server is permanent and can not be replaced, but there are some software (third parties) that can rename tables in SQL Server or Solution #2 is export your database into the form of .sql and edit the table name from the .sql then import