how to transfer from MySql to Management Studio - mysql

I have database which works on MySql. And i need to copy it to another computer where there is only management studio. i create .sql file from MySql and tried to run it in studio but always have syntax errors.
How to do it correctly?
CREATE TABLE branches (
idbranches int(11) NOT NULL AUTO_INCREMENT,
address varchar(200) NOT NULL,
e.g. incorrect syntax for "AUTO_INCREMENT"

The SQL Server syntax is:
CREATE TABLE branches (
idbranches int identity(1, 1) not null,
address varchar(200) NOT NULL
);

Related

Cannot create table with flyway (MYSQL)

I try do create a simple mysql database with Flyway migration, but it doesn't going well.
I have created my .sql it named as V1_0__init.sql and I've written some sql commands there:
CREATE TABLE User (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
created DATE NOT NULL,
username varchar(15) NOT NULL,
password varchar(15) NOT NULL,
email varchar(40) NOT NULL,
status boolean NOT NULL,
unique(username)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I think it should be fine, but I have two errors, one at the first line (CREATE TABLE) and another at the fourth line (created DATE NOT NULL).
The error message says:
Invalid or Incomplete statement
Expected one of the following: ALGORITHM DEFINER SQL VIEW
(At the 'created DATE NOT NULL' line have a similar message, the only difference is this: Algoritm definer OR sql view)
I've tried to fix these but it didn't go well.
Anyone could help me how to fix this?
Maybe did I miss something? Should I do something in application.properties?

Could not locate entry in sysdatabases for database

I need this code to run the instant the professor hits the F5 button.
I created a database and I have a problem with the USE statement
SQL just can't switch to the database that USE statement is calling. it's saying this:
could not locate entry in sysdatabases for database
I tried with square brackets ([]) and it's not helping.
The project is about Car Service and its a school project.
I just need that USE statement to run or some other solution so the code can run without error and in one click on F5.
USE master;
IF DB_ID('ServisAutomobila') IS NOT NULL
DROP DATABASE ServisAutomobila;
GO
CREATE DATABASE ServisAutomobila;
USE ServisAutomobila
go
CREATE TABLE Automobil
(
Automobil_ID int identity (1,1) not null,
Model nvarchar (50) not null,
GodinaProizvodnje nvarchar(50) not null,
RegistarskiBroj nvarchar (50) unique not null,
BrojMotora nvarchar (50) unique not null,
BrojSasije nvarchar (50) unique not null,
Kvar nvarchar (250) not null,
TipAutomobila_ID int not null,
Zemlja_ID int not null,
Vlasnik_ID int not null
)
CREATE TABLE Zemlja
(
Zemlja_ID int identity (1,1) not null,
Zemlja nvarchar (50) not null
)
The GO keyword is a batch terminator. So in your example:
CREATE DATABASE ServisAutomobila;
USE ServisAutomobila
go
The batch is executed as one and results in that particular error because the database engine tries do use database ServisAutomobila which does not exists yet. This means that you must add that extra GO suggested in the previous comments before you can use the newly created database:
CREATE DATABASE ServisAutomobila;
GO;
USE ServisAutomobila;
GO;

mysql and sql developer

I found how to make sql developer connect to a mysql server and then I made a database. The problem I now have is that I cannot add my tables to it. Is it a syntax problem or am I doing something wrong? I have used (use database;) but now I see and error on some lines. Like in line 352, but it looks fine....
CREATE TABLE acctmanager
(amid VARCHAR2(4) PRIMARY KEY,
amfirst VARCHAR2(12) NOT NULL,
amlast VARCHAR2(12) NOT NULL,
amedate DATE DEFAULT SYSDATE,
region CHAR(2) NOT NULL);
there is no varchar2 in MySQL
replace varchar2 with varchar

WordPress WP-Dbmanager 0/1 Query(s) Executed Successfully

WordPress 3.5.1
WP-DBManager 2.63
Database Type MYSQL
Database Version v5.1.68-cll
Trying to create new table on database for WordPress site using the WP-DBManager plugin.
I click on the Run SQL Query link in the Admin panel and paste in my query which is
CREATE TABLE mg_msl_lookup
(
device_id INT(11) NOT NULL auto_increment,
sku VARCHAR(30) NOT NULL,
manufacturer VARCHAR(30) NOT NULL,
phone VARCHAR(50) NOT NULL,
esn BIGINT(18) NOT NULL,
msl INT(6) NOT NULL
);
I click Run and I get the error message
CREATE TABLE mg_msl_lookup
0/1 Query(s) Executed Successfully
So I did a google search for "WP-Dbmanager 0/1 Query(s) Executed Successfully" and found this forum post on the plugin developer's site. It suggested to put the statement all on one line, so I did:
CREATE TABLE mg_msl_lookup (Device_Id int(11) NOT NULL AUTO_INCREMENT, SKU varchar(30) NOT NULL, Manufacturer varchar(30) NOT NULL, Phone varchar(50) NOT NULL, ESN bigint(18) NOT NULL, MSL int(6) NOT NULL);
Once again I click Run and I get the error message:
CREATE TABLE mg_msl_lookup (Device_Id int(11) NOT NULL AUTO_INCREMENT, SKU varchar(30) NOT NULL, Manufacturer varchar(30) NOT NULL, Phone varchar(50) NOT NULL, ESN bigint(18) NOT NULL, MSL int(6) NOT NULL);
0/1 Query(s) Executed Successfully
I have site wide admin permissions, I can drop/empty tables using the plugin GUI, but for some reason can't create a simple table. I have 40 tables before and after I run the statement.
The plugin developer has these set of instructions on the Run Query page
CREATE statement will return an error, which is perfectly normal due to the database class. To confirm that your table has been created check the Manage Database page.
UPDATE statement may return an error sometimes due to the newly updated value being the same as the previous value.
ALTER statement will return an error because there is no value returned.
I'm gathering that what he means in #1 is that when you run a CREATE statement it will error (so perhaps 0/1 Query(s) Executed Successfully is normal?) so I followed the directions and go back to the Manage Database page but my new table is not there.
Does anyone have any experience with the WP-DBManager that could assist with this ? This is getting rather frustrating.
I opted to use phpMyAdmin to create the tables instead of the plugin, worked like a charm.

retrieve mysql output from django 'manage.py sql appname'

I was wondering if there is a way to retrieve the MySQL code for DB setup. Right now it's using sqlite for output when I run 'manage.py sql management'
See below:
MB-PR0:users jg$ python manage.py sql management
BEGIN;
CREATE TABLE "management_service" (
"id" integer NOT NULL PRIMARY KEY,
"service_name" varchar(32) NOT NULL
)
;
CREATE TABLE "management_employee_services" (
"id" integer NOT NULL PRIMARY KEY,
"employee_id" integer NOT NULL,
"service_id" integer NOT NULL REFERENCES "management_service" ("id"),
UNIQUE ("employee_id", "service_id")
)
;
CREATE TABLE "management_employee" (
"id" integer NOT NULL PRIMARY KEY,
"first_name" varchar(32) NOT NULL,
"last_name" varchar(32) NOT NULL,
"email" varchar(32) NOT NULL,
"gmail_active" bool NOT NULL,
"employee_status" bool NOT NULL
)
;
CREATE TABLE "management_note" (
"id" integer NOT NULL PRIMARY KEY,
"note_name" text NOT NULL,
"employee_id" integer NOT NULL REFERENCES "management_employee" ("id")
)
;
COMMIT;
Is there a way to have this output as MySQL?
Thanks!
Change your settings.py file to use
MySQL
run manage.py sql management
Change your Settings.py file back.
I think that should work. I've never tried it though.
This looks like basic SQL syntax. Can't you use this script by just running it via commandline?
$ mysql <my_db_name> -u<user_name> -p < mysql.sql
(This is using commandline redirecting)
You will be asked for your password after pressing enter, then the script is executed.
Before that you can check if it is installed:
$ mysql -V
..or do you have phpmyadmin or the MySQL "IDE" installed? At least from the last one you could execute the script from a GUI desktop application, if needed.