Easy edit and delete row from mysql - mysql

I'm not that good at mysql but some of my tables has this line where I can edit and delete the row easy without writing any SQL? How can I make that row inside another table?

You can use any GUI editor like phpmyadmin or the tools which P.Salmon mentioned.
Using GUI editor, you can connect to the database using connection string and you can view tables and see the result which can edited and deleted.

Related

update mysql from a sql file

Im new to the php and mysql. I have been coding an auto update script. Everything works fine as I can download the latest version files from my own host which includes of the sql file of mysql. All I want to do an update due to this sql file.
What I want this code to do is;
If there is new tables, add it to the mysql and if we have deleted 1 table it can check and delete the same table from mysql.
But while we are doing this update, we will have so many entries under columns so I dont want it to update the columns which has entries in it. But if this is a column that we have deleted from the source sql file then it will delete it.
If there is new column on the source sql file then it will add that column to the mysql.
Any possibility can help me? Try to find if I can find something similiar but I couldnt see. Thats why I opened a topic here.
Thank you very much

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;

Migrating from MySQL to DB2 iSeries

So I don't want this thread to be marked as spam, as a previous thread was on this topic was, so I will explain what I have done so far and my issue is and ask if there are any solutions.
I have a MySQL database on my laptop that I need to migrate to DB2 on iSeries. I'm using a tool, I won't say which one because of the spam issue, which allows me to "copy" a table in my MySQL database and "paste" it into my DB2 database.
The issue that I'm having is because the table names and column names contain spaces in the MySQL db, the tool is failing on the paste. I confirmed this by altering one table by replacing the spaces with underscores and the copy worked perfectly. I have over a hundred tables I need to copy over and don't want to have to manually edit every table and column name.
Is there a way to globally replace spaces with underscores in MySQL table names and columns?
Any other ideas? I'm also researching a way to force the query the tool creates to enclose the object names in quotes, but have had no luck so far.
Thanks for any help and suggestions you can provide.
Since Stack Overflow is about helping to solve programming problems, I'm going to ignore the issue of deficiencies in the chosen tool and propose a programming solution to the larger problem - DB2 does not allow spaces in table and column names. You did ask for any suggestions...
Write code that reads the MySQL catalog tables. In DB2 they'd be SYSTABLES, SYSVIEWS, SYSINDEXES, SYSCOLUMNS, etc. Read SYSTABLES and use that as the 'primary' source for the rest of the code. Check the table name; if it has an embedded space, replace it with an underscore. Use SYSCOLUMNS to generate a CREATE TABLE statement that will create the new table (in a new MySQL database?) - also performing space to underscore replacement. After issuing the CREATE TABLE, generate an SQL statement that will INSERT INTO the new table the columns from the old table; again doing the space to underscore substitutions. Once the new table is populated, generate SQL statements to CREATE VIEW, CREATE PROCEDURE, CREATE FUNCTION, etc.
The general idea is that you will completely re-create your MySQL database with table, view and column names that are immediately compatible with DB2 for i so that your tool can do it's thing.
Of course, if you go to that much trouble it'll probably be just as easy to directly CREATE TABLE, etc on the IBM i side rather than go through an intermediate tool that isn't quite what you need.

MySQL Workbench Inserts

I am using MySQL Workbench 5.2.28 for designing my database schema. I need to insert default data into some tables which can be done using the "Inserts" tab. However, it seems like it only allows entering data manually, one row at a time. I have an OUTFILE with several hundred rows that I would like to insert.
Is this possible with MySQL Workbench? Would creating separate MySQL scripts for importing default data be a better approach?
I am now using separate sql scripts for inserting my data as there doesn't seem to be an easy way to add bulk inserts to MySQL workbench.
Generate CSV (quoted if you have comas in values) in Excel for example, then just copy/paste all rows into workbench via 'inserts' tab for each table in model.
Works with Workbench version 5.2.40.
In the MySQL Workbench Version 6.2 you will find a Import Button which alows you to Import Inserts from a CSV File with "," as delemiter.
You are right there is no way I know doing this automatically. The only thing you can do is to generate all your inserts scripts in a single time by doing a forward engeniering and then by copying the insert statements at the end of the generated script (You must check the option "Generate INSERT statements").

How to show MYSQL statements that show how to create a particular table?

I've created and edited a couple of tables and don't want to recreate them from scratch if the database gets erased. What command allows me to "export" the field names and settings (NOT the content) as a ready to use MYSQL command that I can paste back on the MYSQL prompt?
SHOW CREATE TABLE tablename;
Reference: mySQL docs