Deleting mysql db syntax? - mysql

Im trying to tidy up my local dbs which are left over duplicates and dev dbs from past projects.
To do it im viewing in Sequel pro, then im deleting them using the command DROP DATABASE testdatabase; that works fine.
But some of my dbs have names like lorem-blog-db (with dashes) when i try to run DROP DATABASE lorem-blog-db; it gives me back an error near 'lorem-blog-db'.
Any idea how to resolve this ? i guess its to do with the dashes.

In MySQL, you can use backticks to escape names. Like so:
DROP DATABASE `my-least-favorite-db`

Related

Mysql creating table issue

I started learning SQL but just in my first query, failed, i was doing exactly the same as the mentor explaining in the course but somehow his code worked mine not.
I also tried this query on PopSql it also did not work.
What is wrong here?
You need to select the database you are running this query on.
To do this via MySQL Workbench:
Click on the 'Schemas' tab highlighted below:
Then double click on the name of the database you are trying to run the query on, the database name will be bolded once selected.
You need to tell MySQL which database to use:
USE database_name;
before you create a table.
In case the database does not exist, you need to create it as:
CREATE DATABASE database_name;
followed by:
USE database_name;

Moving MS SQL Server image data to MySQL longblob

I'm wondering what is the best route to move image data in a SQL Server database to a MySQL server database? Is it possible via SQL?
So far I have created a linked server on the MS SQL Server that links to the MySQL table. I'm able to upload blobs on the MySQL server when I am on it locally (using the LOAD_FILE function...but trying to stay away from that since the images need to be on the MySQL host for that function to work). Is there another way to insert blobs into MySQL without using the LOAD_FILE?
I'm thinking there should be a way to break down the MS SQL Server image field to binary and then insert that into the MySQL database via the linked server?
Yes, I found that SQL Server seems to implicitly convert the image to varbinary(max)....I was able to get this to work using the OPENQUERY method.
{INSERT INTO OPENQUERY(MYSQLLINKEDSRV, 'select name, file from mysqlTable')
SELECT TOP 10 name, file from mssqlTable; }
This seemed to work for me as well...
{INSERT INTO MYSQL...mysqlTable(name, file) VALUES ('name','xxxxx')}
I did notice that when I was inserting into MySQL through the linkedserver that the first column of the inserted record was null....to fix this I moved my integer columns to the end of my insert statement and it seems to work fine, I'm still looking into how to handle this if there are no integer columns...don't really want to have a dummy column in my mysql table if I don't have to...

Is there any way to get MYSQL command suggestions inside java statement?

Hi I am working on this project but I'm in a hurry. It's really annoying to copy MySQL table and column names, especially when I join them. I use netbeans 8.0.2 so I am wondering is there anyway to get MySQL command suggestions in my statement String area?

Opening huge mySQL database

I want to open a Huge SQL file (20 GB) on my system i tried phpmyadmin and bigdump but it seems bigdump dose not support more than 1 GB SQL files is there any script or software that i can use to open,view,search and edit it.
MySQL Workbench should work fine, works well for large DB's, and is very useful...
https://www.mysql.com/products/workbench/
Install, then basically you just create a new connection, and then double click it on the home screen to get access to the DB. Right click on a table and click Select 1000 for quick view of table data.
More info http://mysqlworkbench.org/2009/11/mysql-workbench-5-2-beta-quick-start-tutorial/
Try using mysql command line to do basic SELECT queries.
$ mysql -u myusername -p
>>> show DATABASES; // shows you a list of databases
>>> use databasename; //selects database to query
>>> show TABLES; // displays tables in database
>>> SELECT * FROM tablename WHERE column = 'somevalue';
It totally depends on the structure of the database, one way of handling this is by exporting each table in a seperate sql file, as for editing the file, you're limited to opening the raw sql files in notepad or any other text editor. But you probably already knew that.
What are the settings that were used to export the database? People often forget that there's also an option to turn on comments, for big databases it makes sense to turn that off.
To get a more detailed answer have you tried asking at https://dba.stackexchange.com/?

special characters in mysql

I have a mysql DB contains arabic data. when opening the db via mysql workbench the data looks like "ßÇÙã ÇáÌãÇÓí".
when making a simple php file that read from the DB the data looks fine(arabic).
but when reading the data via ASP.net the data looks like "ßÇÙã ÇáÌãÇÓí".
Please help me.
Before running SELECT query from your ASP.net application try running two queries after you connect to the database:
SET CHARACTER SET 'utf8';
SET NAMES utf8;
Basically you need to make your app aware of possible international characters.
P.S. This should be run again every time connection is established, e.g. you can't run it once from MySQL workbench and fix your app. Your app need to do that on its own.