ROW_FORMAT=DYNAMIC sql query bug - dynamic

this is the query :
CREATE TABLE `pedidos_detalle` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`fk_pedido` int(11) DEFAULT NULL,
`fk_articulo` int(11) DEFAULT NULL,
`precio` decimal(10,2) DEFAULT NULL,
`cantidad` int(11) DEFAULT NULL,
`importe` decimal(10,2) DEFAULT NULL,
`detalle` text,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=16503 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
The result of this query is the error message : #1005 - Can't create table 'netlogiq_acros.pedidos_detalle' (errno: 1478)
If i removed the ROW_FORMAT=DYNAMIC it works, but I know don't what will be the effects on the feature . Or if changed the InnoDB to MyISAM it also works. but still I do not know what will be effects. Can someone help me how to manage this ? explain me the differencet between myIsam and Innodb and for what reason I should use ROW_FORMAT=DYNAMIC or COMPRESSED ? thx

innoDB and MyIsam are Table formats. MyIsam is the older on and has been standard up until mysql 5.5. which version are you using? you can read about the advantages and disadvantages of both on wikipedia. i would recommend to use innoDB.
the meaning of the setting ROW_FORMAT = DYNAMIC is explained here: http://dev.mysql.com/doc/innodb-plugin/1.0/en/innodb-row-format-dynamic.html
but why would want this setting to be applied? as far as i understood, you do not know what ist exactly does? in this case i would prefer the working solution that i also do not understand over the not working solution that i still do not understand. Or do you have an external requirement?
I hope this helps.

Related

Can't create graph tables with sqlproj

After getting really fed up with using hierarchyids to manage my node tree, I decided to take a stab at using SQL Server 2017's graph functionality to ease my troubles.
I have a little bit of confusion, though. Currently, all of my SQL scripts are stored and organized in a SQL database project. When I create a node table and publish it to my Azure SQL Database, it only creates a standard table.
However, I can paste the exact same query into SSMS and it creates the graph table just fine. I've included the query below. Am I missing anything obvious?
CREATE TABLE [dbo].[GraphSite]
(
[SiteId] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(),
[SiteName] NVARCHAR(100) NOT NULL,
[SiteTypeId] UNIQUEIDENTIFIER NOT NULL,
[SiteTimeZone] NVARCHAR(20) NOT NULL DEFAULT N'America/New_York',
[SiteStatusId] UNIQUEIDENTIFIER NULL,
[SiteThemeId] UNIQUEIDENTIFIER NULL,
CONSTRAINT [PK_GraphSite] PRIMARY KEY ([SiteId]),
CONSTRAINT [FK_GraphSite_SiteType] FOREIGN KEY ([SiteTypeId]) REFERENCES [SiteType]([SiteTypeId]),
CONSTRAINT [FK_GraphSite_SiteStatus] FOREIGN KEY ([SiteStatusId]) REFERENCES [SiteStatus]([SiteStatusId]),
CONSTRAINT [FK_GraphSite_SiteTheme] FOREIGN KEY ([SiteThemeId]) REFERENCES [SiteTheme]([SiteThemeId])
) AS NODE;
EDIT: I installed SQL Server 2017 locally and it leaves "AS NODE;" in fine. So SSDT seems to have an issue building graph tables to Microsoft Azure SQL Database v12. Which is weird, considering Azure SQL databases fully support graph tables. Any thoughts?
Could you try downloading the latest version of SSDT from here: https://learn.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt
This should fix the problem for you.

How to tell HSQLDB to allow identity definition for SERIAL?

I'm currently writing tests for a spring boot application which is using a postgreSQL database. During test I want to replace the database by some in-memory variant like H2 or HSQLDB. Sadly both do not behave the same as the postgreSQL database.
I have migrations that look like
CREATE TABLE foo(id BIGSERIAL PRIMARY KEY, ...)
This results in hsqldb telling me
SQL State : 42525
Error Code : -5525
Message : identity definition not allowed: FOO_ID
So apparently creating the matching sequence for the primary key is forbidden. Is there a way to tell hsqldb to accept this?
You need to set PostgreSQL compatibility mode in HSQLDB.
SET DATABASE SQL SYNTAX PGS TRUE
Your table definition is then accepted and converted internally to the SQL Standard equivalent.
CREATE TABLE FOO(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY, ..

How can I create a SQLite3 database file using a SQL command file?

I have a file which contains some SQL commands, something that looks like this:
CREATE DATABASE IF NOT EXISTS `db_name`;
USE `db_name`;
CREATE TABLE IF NOT EXISTS `customers` (
`id` int(10) unsigned NOT NULL,
`f_name` varchar(50) DEFAULT NULL,
`l_name` varchar(50) DEFAULT NULL,
`company_name` varchar(200) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`phone` varchar(25) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `customers` (`id`, `f_name`, `l_name`, `company_name`, `email`, `phone`) VALUES
...
...
...
I'd like to use these commands to create an SQLite3 database file in order to use it easily with Python.
How do I do that on Ubuntu?
That isn't quite an SQL file, that contains a bunch of MySQL-specific stuff some of which SQLite will accept and some it won't. We'll start at the top.
You don't need create database or use with SQLite. If you want to create a database just name it when you run sqlite3 from the command line:
$ sqlite3 db_name.sqlt < your_sql.sql
If db_name.sqlt exists then it will be used, if it doesn't exist then it will be created. So create database and use are implied by how you run sqlite3. You might need to use a different extension depending on what Python wants to see.
The backticks for quoting are a MySQLism, double quotes are the standard quoting mechanism for identifiers. Lucky for you, SQLite will accept them so you can leave them alone.
SQLite won't know what int(10) unsigned means, you'll have to remove the unsigned before SQLite will accept it. SQLite also won't know what ENGINE=InnoDB DEFAULT CHARSET=utf8 means so you'll have to remove that as well.
You'll probably run into other things that MySQL is happy with but SQLite is not. You'll have to try it and fix it and try it and fix it until it works. Or try to find a tool that can translate between databases for you, I always do these sorts of things by hand or using one-off scripts so I don't know of any tools that can help you.
Basically above commands are for mysql or other database (most of these have to be tweaked in order to work with sqlite. Sqlite stores database in the form of file. Basically when you start sqlite it will create a file (if not present). You can create or open a database by typing
sqlite3 db
on command line. This statement create or open database named "db"

DokuWiki and SQL code

I recently installed DokuWiki on my domain and ran in one nasty problem.
I am trying to enter such code:
CREATE TABLE LOOM(
ID INT NOT NULL,
KIIP_ID INT NOT NULL,
NIMI VARCHAR(50) NOT NULL,
SYND DATE NOT NULL,
SURM DATE,
PRIMARY KEY (ID));
between tags and if I am trying to preview or save the change, DokuWiki shows me this:
This topic does not exist yet
You've followed a link to a topic that doesn't exist yet. If permissions allow, you may create it by using the Create this page button.
How to fix this?
See http://www.dokuwiki.org/faq:mod_security
You should escape the commands between the <code></code> tags. Like the below.
<code>
CREATE TABLE LOOM(
ID INT NOT NULL,
KIIP_ID INT NOT NULL,
NIMI VARCHAR(50) NOT NULL,
SYND DATE NOT NULL,
SURM DATE,
PRIMARY KEY (ID));
</code>
If you still have problems previewing then Andreas is right it is most likely a web server configuration issue with Apache. To validate that you could redploy on nginx and see if the issue still persists. I have a tutorial about deploying dokuwiki on nginx here: http://bigthinkingapplied.com/launching-a-private-wikipedia-using-dokuwiki/

Tools for Migrating from Oracle to MySQL

I want to migrate schema from Oracle to MySQl, so are there any free tools that would be useful for this task?
I have "Create table" statements in Oracle SQL Script, but it contains unique constraints and a foreign key. MySQL has MyISAM storage engine, and so foreign key is not supported.
How to solve this issue?
Sample Oracle create statements:
CREATE TABLE channels
(
obt_id NUMBER(19) PRIMARY KEY,
discriminator VARCHAR2(64) NOT NULL
CONSTRAINT check_channel_discriminator CHECK (discriminator IN ('CHANNEL','SALES_CHANNEL')),
chan_id VARCHAR2(255),
description VARCHAR2(255),
name VARCHAR2(255) NOT NULL,
obt_version VARCHAR2(255),
fk2_channel NUMBER(19)
CONSTRAINT fk_channel_channel REFERENCES channels(obt_id)
);
CREATE TABLE object_types
(
obt_id NUMBER(19) PRIMARY KEY,
enum_value VARCHAR2(64) NOT NULL,
external_name VARCHAR2(64) NOT NULL,
description VARCHAR2(255),
business_validation NUMBER(1) DEFAULT 0,
start_date_time DATE DEFAULT to_date('01011900','DDMMYYYY'),
end_date_time DATE DEFAULT to_date('01014712','DDMMYYYY'),
mut_date_time DATE DEFAULT SYSDATE,
mut_user VARCHAR2(32) DEFAULT USER,
CONSTRAINT object_types UNIQUE (external_name,start_date_time,end_date_time)
);
I have not heard of a single tool that can assist in what you are asking for. This does not mean one does not exist, however, it is probably easier and less error prone to take your existing Oracle scripts and manually create the appropriate MySQL scripts. On every project I have been on the DBAs were responsible for data migration of this type and they always did it manually.
Edit:
That being said I did a quick google search and there are a few programs that claim to do this (at a cost). For example:
Oracle to MySQL
Data loader
DBConvert
I would obviously caution against using a third party tool and make sure you back up everything before starting.
The mysql gui tool kit includes a migration tool.
http://dev.mysql.com/downloads/gui-tools/5.0.html
You'll need to have the jdbc driver for Oracle installed on the machine where your running the tool kit.