What's the difference between Oracle and Mysql when interpreting "Create Database "? - mysql

I used to use mysql, and in mysql database hold tables, but these concepts doesn't apply to oracle, so I don't quite understand the differences.
Update: The problem I am facing is, I need to do migration from Mysql to Oracle.
I have two switching databases called A and B, in Mysql all the tables are in their corresponding databases.
In mysql database is a logical concept, it use database to hold tables, in oracle database is physical concept, I don't know how to design this in oracle.
Do I need to use "CREATE DATABASE" to create two databases in oracle to achieve the same effect?

To answer your question you want to create a schema (CREATE USER) not an instance/database (CREATE DATABASE).
The Oracle definition of a database is the files on disk. These can be shared between instances (Real Application Clusters) or only used by a single instance (on the same server for example, the most common).
Background: The concept of "database" is different between database vendors. As an Oracle DBA I'm careful when talking to someone who is from an MySQL, DB2, SQL Server background, what they call a "database" in Oracle is a user/schema (difference between user and schema being a schema contains tables and a user is only a login). Whenever someone, developer especially, uses the word "database" question in what context.

Oracle's SQL Developer documentation has a chapter comparing MySQL with Oracle. Find it here. The reason it is here is because SQL Dev includes the Migration Workbench which supports migrating MySQL to Oracle. You might want to consider using the tool in your endeavours. It is free.
Anyway, the documentation has this answer to your specific question:
"When migrating MySQL databases to
Oracle, SQL Developer maps each MySQL
database to a tablespace in Oracle.
Database objects, such as tables,
indexes and views are stored in the
respective tablespaces and are
referenced from the Oracle schema for
the user that owns them."

Related

Can I use either SQL, MySQL or SQLite to read a SQL database?

I'm not very versed on databases, so thismight sound wrong to some of you: Can I use SQL, MySQL and/or SQLite to read the same database? If so, are there commands or instructions I should keep an eye on to not make a mess on the tables?
Thanks in advance!
sql is a language. sqlite and mysql are database engines.
Both SQLite and MySQL (as far as any SQL engines) allows SQL language to manipulate database content (with some engine specific ).
So you may use SQL to read a MySQL or SQLite database. But be aware that SQL use in each is engine dependent. For instance, in SQLite you may use shell application, c wrapper, ... For MySQL you may use php wrapper, ...

Querying data by joining two tables in two databases (different database types) on different servers

I have a MS SQL (SQL Server 2008) database with some data in it and a postgresql (9) database with other data. I need to do some queries to find related data. I know how to link two MS SQL databases together but not sure how to even start with the mixed database types.
The new company I work for has postgresql, I have not worked with it before. The guy I replaced was really the only one here who knew much about it. So no internal resources.
I'm not ready to build a solution in code at this point (.NET), just hoping to have a tool to do some queries.
Postgresql has table
Company
Company_id, Company_name, ....
MS SQL had table
Companies
company_name, postgresql_company_id, company_id, ....
If you ever need to run queries from Postgres that pulls data from SQL-Server, you can use foreign data wrappers. The ODBC driver should work fine:
http://wiki.postgresql.org/wiki/Foreign_data_wrappers
I'm not familiar enough with SQL-Server to give an authoritative answer on how to do it the other way around, but since Postgres speaks ODBC, I'm guessing it's close enough to how you make a SQL-Server talk with another one.
Related thread: SQL Server 2012: Add a linked server to PostgreSQL

how to make a database secondary on mysql server..?

Is there any way of making a database offline/down/inactive/secondary on MYSQL SERVER ...so that when we query like SHOW DATABASES it will give us the list of active/online/primary databases....?
Also making these databases down/secondary will affect the synching with other database servers?
Actually it's not a database, it's a schema (show databases). You can down the whole instance but not schema.

Difference Between Schema / Database in MySQL

Is there a difference between a schema and a database in MySQL? In SQL Server, a database is a higher level container in relation to a schema.
I read that Create Schema and Create Database do essentially the same thing in MySQL, which leads me to believe that schemas and databases are different words for the same objects.
As defined in the MySQL Glossary:
In MySQL, physically, a schema is synonymous with a database. You can substitute the keyword SCHEMA instead of DATABASE in MySQL SQL syntax, for example using CREATE SCHEMA instead of CREATE DATABASE.
Some other database products draw a distinction. For example, in the Oracle Database product, a schema represents only a part of a database: the tables and other objects owned by a single user.
Depends on the database server. MySQL doesn't care, its basically the same thing.
Oracle, DB2, and other enterprise level database solutions make a distinction. Usually a schema is a collection of tables and a Database is a collection of schemas.
Refering to MySql documentation,
CREATE DATABASE creates a database with the given name. To use this
statement, you need the CREATE privilege for the database. CREATE
SCHEMA is a synonym for CREATE DATABASE as of MySQL 5.0.2.
PostgreSQL supports schemas, which is a subset of a database:
https://www.postgresql.org/docs/current/static/ddl-schemas.html
A database contains one or more named schemas, which in turn contain
tables. Schemas also contain other kinds of named objects, including
data types, functions, and operators. The same object name can be used
in different schemas without conflict; for example, both schema1 and
myschema can contain tables named mytable. Unlike databases, schemas
are not rigidly separated: a user can access objects in any of the
schemas in the database they are connected to, if they have privileges
to do so.
Schemas are analogous to directories at the operating system level, except that schemas cannot be nested.
In my humble opinion, MySQL is not a reference database. You should never quote MySQL for an explanation. MySQL implements non-standard SQL and sometimes claims features that it does not support. For example, in MySQL, CREATE schema will only create a DATABASE. It is truely misleading users.
This kind of vocabulary is called "MySQLism" by DBAs.
in MySQL schema is synonym of database.
Its quite confusing for beginner people who jump to MySQL and very first day find the word schema, so guys nothing to worry as both are same.
When you are starting MySQL for the first time you need to create a database (like any other database system) to work with so you can CREATE SCHEMA which is nothing but CREATE DATABASE
In some other database system schema represents a part of database or a collection of Tables, and collection of schema is a database.
Yes, people use these terms interchangeably with regard to MySQL. Though oftentimes you will hear people inappropriately refer to the entire database server as the database.
Simply if you are thinking or discussing about Mysql. Then take a simple answer
"SCHEMA & DATABASE are exactly the same thing, just a synthetic
sugar in mysql."
Just add some more info:
MongoDB also distinguish schema from database.
schema represent the tables, which means the structure of database.
Microsoft SQL Server for instance, Schemas refer to a single user and is another level of a container in the order of indicating the server, database, schema, tables, and objects.
For example, when you are intending to update dbo.table_a and the syntax isn't full qualified such as
UPDATE table.a the DBMS can't decide to use the intended table. Essentially by default the DBMS will utilize myuser.table_a
not like Postgres, SQL server schema is set of database have same thing
but in mysql schema and database it is the same
MySQL does not support the concept of schema. In MySQL, schema and schemas are synonyms for database and databases.
When a user connects to MySQL, they don't connect to a specific database. Instead, they can access any table they have permissions for

Combine several mssql database to one mysql with php

We are handling a data aggregation project by having several microsoft sql server databases combining to one mysql database. all mssql database have the same schema.
The requirements are :
each mssql database can be imported to mysql independently
before being able to import each record to mysql we need to validates each records with a specific createrias via php.
each imported mssql database can be rollbacked. It means even it already imported to mysql, all the mssql database can be removed from the mysql.
we would still like to know where does each record imported to the mysql come from what mssql database.
All import process will be done with PHP .
we have difficulty in many aspects. we don't know what is the best approach to solve our problem.
your help will be highly appreciated.
ps: each mssql database has around 60 tables and each table can have a few hundred thousands .
Don't use PHP as a database administration utility. Any time you build a quick PHP script to transfer records directly from one database to another, you're going to cause yourself a world of hurt when that script becomes required for production operation.
You have a number of problems that you need solved:
You have multiple MSSQL databases with similar if not identical tables.
You have a single MySQL database that you want to merge the data into.
The imported data must be altered in a specific way before being merged.
You want to prevent all duplicate records in your import.
You want to know what database each record originally came from.
The solution?
Analyze the source MSSQL databases and create a merge strategy for them.
Create a database structure on the MySQL database that fits the merge strategy in #1, including all the new key constraints (like unique and foreign keys) required for the consolidation.
At this point you have two options left:
Dump the data from each of the source databases into raw data using your RDBMS administration utility of choice. Alter that data to fit your merge strategy and constraints. Document this, and then merge all of the data into your new database structure.
Use a tool like opendbcopy to map columns from one database to another and run a mass import.
Hope this helps.