How To See SQL Code in phpmyadmin SQL Table - mysql

I am trying to see the manual SQL code for a table I created using the graphical user interface. Is there a way to do this and if so how?

use
SHOW CREATE TABLE tablename
see manual

nbk is correct that you would use the SHOW CREATE TABLE command, which is also implemented graphically in phpMyAdmin. From the database structure page (where you see a list of tables), click to select the checkbox for any tables you wish to see the syntax for and the use the "With selected:" dropdown menu on the page to pick "Show create".
It does the same thing, but using the phpMyAdmin interface.
"With selected:" dropdown on the table page
Output of "Show create"

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;

Change existing MySQL table inside NetBeans

I created a table inside NetBeans but one column is wrong type, it should be char instead of int. Is it possible to change it or do I have to delete the whole table and start again?
I searched all context menus but can't find "modify"/"edit" option.
my suggestion also you have two options :
1) By using Netbeans, you could edit (change) the current mysql table via Command Execution.
2) By using mysql ADministrator tool, such as MySQL Query Browser from mysql GUI Tool itself
Happy coding!
you can right click on the column name and select "delete option", then right click on the table name and select "add column" option.

How to Join tables in MySql workbench?

How do I Join tables with mySql workbench visually? without using any SQL script or typing it into the query menu? I am new when it comes to using this MySql workbench, but I tried looking at their documentation and I haven't found any, any help??
Please try these links:
http://net.tutsplus.com/tutorials/databases/visual-database-creation-with-mysql-workbench/
http://www.packtpub.com/article/visual-mysql-database-design-in-mysql-workbench
They give some good screenshot-oriented tutorials (especially since this is for using the graphical user interface to create your database and its objects)
To join tables without using any SQL script or typing it into the query menu:
1) Use the EER diagram: on the menu bar ==> FILE ==> select NEW MODEL from the dropdown, then ==> click on the "Model" tab use dropdown to "Add Diagram", that will open the grid screen where you can simply click on the GUI's on the left side of the grid to create tables, join tables... you'll need to save your model for future use, if needed.

Is there a way to view past mysql queries with phpmyadmin?

I'm trying to track down a bug that's deleting rows in a mysql table.
For the life of me I can't track it down in my PHP code, so I'd like to work backwards by finding the actual mysql query that's removing the rows.
I logged in to phpmyadmin, but can't find a way to view the history of past sql operations.
Is there a way to view them in phpmyadmin?
Ok, so I actually stumbled across the answer.
phpMyAdmin does offer a brief history. If you click on the 'sql' icon just underneath the 'phpMyAdmin' logo, it'll open a new window. In the new window, just click on the 'history' tab.
That will give you the last twenty or so SQL operations.
There is a Console tab at the bottom of the SQL (query) screen. By default it is not expanded, but once clicked on it should expose tabs for Options, History and Clear. Click on history.
The Query history length is set from within Page Related Settings which found by clicking on the gear wheel at the top right of screen.
This is correct for PHP version 4.5.1-1
You just need to click on console at the bottom of the screen in phpMyAdmin and you will get the Executed history:
To view the past queries simply run this query in phpMyAdmin.
SELECT * FROM `mysql`.`general_log`
if it is not enabled, run the following two queries before running it.
SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';
I don't think phpMyAdmin lets you do that, but I'd like to hear I'm wrong.
On the other hand you can enable query logging in MySQL: The General Query Log
Yes, you can log queries to a special phpMyAdmin DB table.
See SQL_history.
I am using phpMyAdmin Server version: 5.1.41.
It offers possibility for view sql history through phpmyadmin.pma_history table.
You can search your query in this table.
pma_history table has below structure:
You have to click on query window just below the phpMyAdmin logo, a new window will open.
Just click on SQL History tab. There you can see history of SQL Queries.
OK so I know I'm a little late and some of the above answers are great stuff.
As little extra though, while in any PHPMyAdmin page:
Click SQL tab
Click 'Get auto saved query'
this will then show your last entered query.
I may be wrong, but I believe I've seen a list of previous SQL queries in the session file for phpmyadmin sessions
Here is a trick that some may find useful:
For Select queries (only), you can create Views, especially where you find yourself running the same select queries over and over e.g. in production support scenarios.
The main advantages of creating Views are:
they are resident within the database and therefore permanent
they can be shared across sessions and users
they provide all the usual benefits of working with tables
they can be queried further, just like tables e.g. to filter down the results further
as they are stored as queries under the hood, they do not add any overheads.
You can create a view easily by simply clicking the "Create view" link at the bottom of the results table display.
you can run your past mysql with run /PATH_PAST_MYSQL/bin/mysqld.exe
it run your last mysql and you can see it in phpmyadmin and other section of your system.
notice: stop your current mysql version.
S F My English.
why dont you use export, then click 'Custom - display all possible options' radio button, then choose your database, then go to Output and choose 'View output as text' just scroll down and Go. Voila!
There is a tool called Adminer which is capable of doing all phpmyadmin job packed in single tiny php file.
http://www.techinfobit.com/how-to-import-export-database-without-any-extra-installation/

How can I edit a view using phpMyAdmin 3.2.4?

I need to simply edit a very complicated view in phpMyAdmin 3.2.4 but I cannot figure how to do that. Any suggestions?
Thanks!
To expand one what CheeseConQueso is saying, here are the entire steps to update a view using PHPMyAdmin:
Run the following query: SHOW CREATE VIEW your_view_name
Expand the options and choose Full Texts
Press Go
Copy entire contents of the Create View column.
Make changes to the query in the editor of your choice
Run the query directly (without the CREATE VIEW... syntax) to make sure it runs as you expect it to.
Once you're satisfied, click on your view in the list on the left to browse its data and then scroll all the way to the bottom where you'll see a CREATE VIEW link. Click that.
Place a check in the OR REPLACE field.
In the VIEW name put the name of the view you are going to update.
In the AS field put the contents of the query that you ran while testing (without the CREATE VIEW... syntax).
Press Go
Special thanks to CheesConQueso for their insightful answer.
In your database table list it should show View in Type column.
To edit View:
Click on your View in table list
Click on Structure tab
Click on Edit View under Check All
Hope this help
update: in PHPMyAdmin 4.x, it doesn't show View in Type, but you can still recognize it:
In Row column: It had zero Row
In Action column: It had greyed empty button
Of course it may be just an empty table, but when you open the structure, you will know whether it's a table or a view.
try running SHOW CREATE VIEW my_view_name in the sql portion of phpmyadmin and you will have a better idea of what is inside the view
Just export you view and you will have all SQL need to make some change on it.
Just need to add your change in SQL query for the view and change :
CREATE for CREATE OR REPLACE
Select your view in Bookmarked SQL query section then select Delete then click Go button.