sql developer mysql to oracle migration - mysql

I successfuly migrate mysql to oracle. But the only problem is case sensitive on table name and fieldname.Some pages in web said go to tools and option in sql developer and tick the ansi but i cannot find it.
On oracle website forum said it part of migration .
Anybody had new version of sql developer and migrate from mysql ?
E.g
calendarColor become CALENDARCOLOR

I really don't see how this is a problem. Since Oracle's objects are case-insensitive by default, you can continue to query them using SELECT * FROM calendarColor.
If you need them to be case sensitive, use quotes, like:
CREATE TABLE "calendarColor" ( ... );
SELECT * FROM TABLE "calendarColor";
See also: Schema Object Names and Qualifiers

If the table was created using
CREATE TABLE calendarcolor ( calendarColorId NUMBER(10,0) NOT NULL );
then the table name is stored in uppercase internally. When you run a statement like this:
select * from "calendarColor"
then you are telling Oracle: The table name should be treated case-sensitive but as there is not table named calenderColor, only one named CALENDARCOLOR your statement fails.
The fix is very easy: remove the quotes and change the select to
select * from calendarColor

Related

Default Database From SQL Script in MySQL

Is it possible to get a table with a sql script from a specific schema, so I don't have to double click the schema in order to make it like the default/currently active schema in mysql?
This is easily achieved by simply specifying the schema name as part of your SQL statement.
For example, if your schema is named foobar and your table is named myTable:
SELECT *
FROM `foobar`.`myTable`;
The syntax for this is simply:
-- With backticks
`schema_name`.`table_name`
-- Without backticks
schema_name.table_name

Selecting using `database_name`.`viewname`.* syntax in MySQL throws "Unknown table 'database_name.viewname'"

I'm having a strange issue with MySQL and database views.
I have a view defined like this:
CREATE VIEW circuits AS
(SELECT Id, Id AS Old_Id, Name FROM circuits_1)
UNION
(SELECT Id + 1000 AS Id, Id AS Old_Id, Name FROM circuits_2)
I have to join this view with a table that is in another database.
To do so, I usually prefix the table name with its database name, like db_name.table_name.
I've mapped this view using an ORM, specifying its prefix, and the resulting query is this one:
SELECT `webapp`.`circuits`.* FROM `webapp`.`circuits`
But this query returns this error:
#1051 - Unknown table 'webapp.circuits'
However, I've tried to manually run the query and remove the webapp. prefix from the SELECT statement, and it works as expected, throwing no error at all
SELECT `circuits`.* FROM `webapp`.`circuits`
Any idea why this happens?
Is it related to the way the view is defined?
EDIT
Another strange thing:
Even if this query fails:
SELECT `webapp`.`circuits`.* FROM `webapp`.`circuits`
This doesn't:
SELECT `webapp`.`circuits`.Id FROM `webapp`.`circuits`
I was hesitant to answer, as i am not familiar enough with mysql to give a full answer. I did some testing on rextester.com though, and found the following:
If I create a table test(id int), I can query it using its fully qualified object name:
SELECT rextester.test.*
FROM rextester.test
Works, no problem.
If I create a view so_test as (Select 1 id from dual)
I cannot do the same:
SELECT rextester.so_test.*
FROM rextester.so_test
Returns the same error you get.
I cannot conclude too much from this, as i don't know mysql well enough. However, it seems a general issue with views, not the way you created it.
MySQL does not seam to support * rewrite to the matching table columns with in the VIEW.
MySQL 5.6.39
http://sqlfiddle.com/#!9/68f2d3/4
MySQL 5.7
https://www.db-fiddle.com/f/taRV6FLAP6Mf8oMeuniZP3/2
MySQL 8.0.11
https://www.db-fiddle.com/f/taRV6FLAP6Mf8oMeuniZP3/3

MySQL selecting columns from a specific table

I'm learning MySQL and this is probably the most basic of the basic questions I could ask, but I want to make sure I understand the syntax.
I have a MySQL script that created three different databases. If I wanted to select all fields from a specific database's table, I would use
SELECT * from database1.table1
correct? Or would it just be
SELECT * from table1
and if I wanted to select only two fields from another table, would it be
SELECT field1, field2 from database1.table2
or again just the table name?
Both forms are actually fine. In SQL you can qualify names to specify explicitly where a db object is located. This is useful for instance if you have a table2 in 2 different schemas (which is the correct term instead of "database", btw).
As it has been mentioned you can set a default schema to avoid having to add a schema to a reference (like your table2) all the time. If there is no schema given then the default schema (set with the USE schema command) will be taken instead. You still can use an explicit schema (either what is set as default or any other) if you like. This will help when you want to access an object which is not in the default schema.

Is there a way to copy the structure of a table (fields but no data) to a new table in MySQL?

For example, I have a table named movies. It has the fields/columns title VARCHAR(100) and runtime INT(5). It's loaded with 10,000 rows of data.
I want to create another table, let's call it movies_custom, that has all of the same columns, but with none of the data.
Is there a quick SQL statement to do this?
EDIT: Sorry, I noticed the SQL Server tag on this and assumed that was the technology you were using until I saw MySQL in the question title.
You can use the syntax CREATE movies_custom LIKE movies in MySQL
Sure!
In SQL Server you can do this query:
select top 0 * into movies_custom from movies
That creates the table structure without inserting any rows.
Very easy in MySQL:
CREATE newtable LIKE oldtable;
The other answers led me in the right direction, but I had to add the keyword TABLE in order to make it work with MySQL Workbench 6.
CREATE TABLE movies_custom LIKE movies;

Generate table DDL via query on MySQL and SQL Server

Is there an easy way to extract table DDL information, via a query, using either Ms or My SQL server? (preferably both?)
For example, using MySQL Administrator / Navicat for MySql, there is a "DDL" function, which generates the "create table foo (....)" script.
Is there any way to get this information from a query itself, such as:
Select DDL from foo where table_name='bar';
Any have the "Create table bar (.....)" returned to me?
If not - any suggestions?
it's mysql-specific, but SHOW CREATE TABLE <table-name> gives you the DDL for a table.
You have to create that yourself.
You can query INFORMATION_SCHEMA.COLUMNS for the column name and data type.
You can't get the CREATE Table text in a cross platform way, but you can get enough information to build it yourself from the INFORMATION_SCHEMA views.