How to edit the database with pgAdmin4 to connect Heroku - heroku

I am trying to create the database on pgAdmin4 to connect to my heroku application. But I cannot edit SQL file.
How to edit the SQL file, I want to add the data with .sql file
How to create new database
How to change heroku database credentials

How to edit the SQL file, I want to add the data with .sql file
You can use Import/Export tool to add the data from SQL file.
https://www.pgadmin.org/docs/pgadmin4/4.x/import_export_data.html
How to create new database
There is an option to create new database in pgAdmin4.
https://www.pgadmin.org/docs/pgadmin4/4.x/database_dialog.html
How to change heroku database credentials
You can change the database password from pgAdmin4 itself
https://www.pgadmin.org/docs/pgadmin4/4.x/change_password_dialog.html

Related

How to create new oracle database with same structure as another database but without data?

I wanted to create a database with the same structure as another database but without restoring data.
Is good idea use Database Configuration Assistant.
Use dbca (Templates )
Create a template for existing database.
Create a database from template

How to replace Sql Server with Sqlite in Aspnetboilerplate?

I am trying to replace sql server with sqlite as database in aspnetboilerplate following this tutorial. we have to remove previous migrations and add new one before running "update-database" but it gives empty database and running this project gives error " 'SQLite Error 1: 'no such table: AbpEditions". how to populate newly installed sqlite database?
there are SeedHelper.cs and initialHostDbBuilder.cs files in EntityFrameworkCore project, probably for seeding database but i could not figure out how to use them?
Make sure that config files in all of your projects that need the access to the database are pointing to the same file. If you have just used the value from the article
"Default": "Data Source=SqliteDemoDb.db"
then you have a separate database file in each project. The file that the migrations are executed on is in the EntityFramework project.

How to clone Oracle database from one service name to other service name?

I have Oracle database and I know SYS password and service name.
I don't have access to database server.
I want to clone database and want to deploy this copy on this database server, but I want have other service name for access to copy.
For example: first base connection string is localhost:1521/sn1, and clone have connection string localhost:1521/sn2copy.
It is possible?
RMAN has the ability to clone a database.
take a look at the RMAN DUPLICATE command.
It's actually documented in the Oracle documentation: Creating a Duplicate Database on the Local Host
.
And also see (from the ORACLE-BASE Blog): Duplicate a Database Using RMAN in Oracle Database 11g Release 2

nopcommerce 3.40 Deployment cant create database

I installed on localhost with a local database. I compiled in Release mode - Any CPU. I have recopied the file system set from publish to the root folder as always.
I am taken directly to the install page. I try to install using my websites database server name. Ive tried reconnecting to an existing database.
I get the error message (Ive tried both connection methods):
Setup failed: Sequence contains more than one element
So i tried to just create a new database. i get error:
Setup failed: An error occurred while creating the database: CREATE DATABASE permission denied in database 'master'.
I have checked to make sure my username and password are correct for the database. I think maybe i need to reset the install files some how? I have tried everything from delete to editing the settings.txt file in the App_data folder. still cant get passed the install
You don't have permission to create a new database using these credentials. You should configure SQL Server to allow it
Most shared hosting doesn't allow you to create database from code. To overcome this, do:
Manually create database on your host
Get the connection string / connection info
Enter the info in [2] during installation, make sure you uncheck "create database if it doesn't exist"
The nopCommerce install never creates a database. If you so choose... nopCommerce will create tables.
Edit: I am marking this the answer because this concept helped solve both new database creation and connecting to existing databases.

Data migration from Oracle 10g to Postgres db

I want to migrate the data from Oracle 10g database to Postgres db.
Oracle SQL developer has data migration option but it seems its only for migrating non oracle db to oracle.
Please let me know other options.
There's a dedicated tool for that written in Perl: Ora2Pg.
Most databases provide tools for importing from other databases but not exporting to other databases.
I have tried using ORA2PG before but it was too complicated so I found my own way to migrate from sql developer to postgres.
Here's a step by step, let me know if you have any questions.
HOW TO MIGRATE DATA FROM THE ORACLE DATABASE TO THE POSTGRES DATABASE!
Tools to download before migration: SQL Developer, WINSCP
SQL Developer
Step 1: Login into the Oracle server using SQL Developer
Step 2: Right click on the schema name > Export > Change for the format to CSV and the encoding to UTF-8. (Make sure Export DDL is unchecked) (Make sure the filename is finished with .csv )
Step 3: Click next > next > Finish (Wait till the exporting is done)
ONCE THE FILE FROM SQL DEVELOPER IS EXPORTED
Right click on the csv file, click on open with and open it with Notepad.
Click File > Save as > Change encoding to UTF-8 and save it.
Open WINSCP
STEP 1: Before logging in into your server, click on edit > Advanced > Turn ON ‘UTF-8 encoding for filenames’.
STEP 2: Login into your server
STEP 3: Click on Settings > Internal Editors > Change the Default encoding to UTF-8 > Click Ok
STEP 4: Create a new directory anywhere on your server and drag your file to that directory into WINSCP
Now the file should be on your server with the UTF-8 encoding.
Open putty
Before logging in into your server with Putty, click on Translation and change the Received data assumed to be in which character set to UTF-8 then click on DATA and change the Terminal-type string to Putty then login into your server.
Once you logged in into your server with Putty, Run the command:
Locale charmap
This command will show you the default encoding of the server.
Run that command after:
grep -Rw '/home/pgadmin/data1/1234.csv' -e 'fre'
data1 = Directory created on the server
1234.csv = Csv file inside the data1 Directory
This command will show you if the French word in your document are still lost or not.
The '/home/pgadmin/data1/1234.csv' in that command is where your file is located on your server and ‘1234.csv’ is the name of the CSV file.
If everything is good after running that command, now we’re able to put it on the Postgres database.
After entering the postgres database with the command “psql”
Step 1: Make sure you have created your own database, schema and table (if you don’t know how, Scroll down to the end of the document).
Step 2: After creating your own database, schema and table, we can run the copy command.
\Copy joe.data01 FROM ‘home/pgadmin/data1/1234.csv’ DELIMITER ‘,’ CSV HEADER encoding ‘UTF-8’ ;
If the file already has column names on the csv file, add “HEADER” in the command.
joe.data01= Name of table created
home/pgadmin/data1/1234.csv = Location of the file on the server
To view if the schema was copied, simply run the command select * from joe.data01;
To view if French words are not lost, run the command select * from joe.data01 where isa = ‘fre’ ;
How to create a Database on Postgres: CREATE DATABASE name_of_database ;
How to create a Schema on Postgres: CREATE SCHEMA name_of_schema;
How to create a Table on Postgres: create table joe.data01 (ccca CHAR(50) NOT NULL, isa CHAR(70) NOT NULL, co CHAR(150) NOT NULL) ;
We ended up migrating a fairly large database (~100 schema, with >1000 tables) from Oracle to Postgres using the approach outlined at: https://github.com/MIT-LCP/oracle-to-postgres.
You can install the package with pip install oracle2postgres. More information is at: https://pypi.org/project/oracle2postgres/
A Jupyter Notebook demonstrating the approach is at: https://github.com/MIT-LCP/oracle2postgres/blob/master/migration.ipynb.
Our general approach was to mirror the source database; convert data types where necessary; create the target database; copy across the data in chunks. It's a slightly hacky solution, but it worked well for us.
# import the package
import oracle2postgres
# create the logfile
oracle2postgres.create_logfile()
# get source database settings
source_config = oracle2postgres.get_source_config()
# get target database settings
target_config = oracle2postgres.get_target_config()
# get settings for migration
migration_config = oracle2postgres.get_migration_config()
# check the schema exist on the source database
source_engine = oracle2postgres.connect_to_source(source_config)
oracle2postgres.check_schema_exist(source_engine,source_config['schema_list'])
# check for null characters in strings in the source database
# if found, they can be removed as explained in the documentation
oracle2postgres.check_for_nulls(source_engine,source_config['schema_list'])
# create a new database on the target database
target_engine = oracle2postgres.connect_to_target(target_config)
oracle2postgres.create_database(target_config['database'],target_engine)
# create schema on the target database
target_engine = oracle2postgres.connect_to_target(target_config,target_config['database'])
oracle2postgres.create_target_schema(source_config['schema_list'],source_engine,target_engine)
# run the migration
oracle2postgres.migrate(source_config,target_config,migration_config)
If you hit problems when reusing the code, feel free to raise an issue if so and we'll do our best to help.
expand the tables section,
then select tables you want to export
right click, select export,
then select format and export (preferably insert statements or csv)

Resources