Problem with mysql console - mysql

When i login in to my mysql account i doing something like this:
mysql>TRUNCATE MyTable
->
->
->
but there is no response informations but only more -> with every pressed Enter. It is right that there is only more -> and nothing else with every pressed Enter?
For more i can see on my mysql based page that data which i want to remove is still existing. It is normal?

You need to terminate the statement with a semicolon ;
mysql>TRUNCATE MyTable;

Related

How do you execute a query in Sequel Pro?

I want to execute a query in a MySQL DB using Sequel Pro, but I do not see a Run button.
How do I execute my query?
Use ⌘+R to execute the selected Query.
Alternatively, use the dropdown that appears at the bottom right of the query editor and select Run Current or Run Previous depending on where your text cursor is.
Based on Keyboard Shortcuts:
Run all queries ⌥ ⌘ R
Run current query or selection ⌅ or ⌘ R
Use the drop down button on the right side, underneath the textarea.
Should have the following options:
Run Current Query
Run All Queries
Came here to find ⌘ + return to execute a query (like MySQL Workbench).
Found that I can map using mac Key bindings with the names of Run Current Query and Run Previous Query.
If you want to do it via terminal it would be (untested):
defaults write com.sequelpro.SequelPro NSUserKeyEquivalents '{
"Run Current Query" = "#\\U21a9";
"Run Previous Query" = "#\\U21a9";
}'
Note: you may have to restart the app.

MySQL Workbench - How do I set a value to NULL using the GUI? [duplicate]

I'm using the MySQL Query Browser (part of the MySQL GUI Tools) and need to change a field to NULL, but I can't figure out how to do it - if I delete the value it tries to update it to ''. Typing "NULL" makes it try to update to 'NULL' (a string).
I know I could just write a query to do it, but that defeats the entire purpose of the tool, no?
In MySQL Query Browser, right click on the cell and select 'Clear field content' while the focus is in another cell.
In MySQL Workbench, right click on the cell and select 'Set Field to NULL'.
In MySQL Workbench, with the cell selected, press Shift + Delete
Tested on 6.3.4.0
Right-click on that column and select the
'Set field to Null'
option from the context menu.
Removing the contents:
This works for some tools (sorry to hear it doesn't for yours).
This may not appear as null but will when you perform a query.
Shift + Delete
work well in MySql Workbench 8
I'd try Ctrl-0 (zero), because that works in some tools.

What does getting a prompt after creating a database mean?

Everywhere I look I can't find this "EXACT" situation.
I enter: create database october24
after hitting return I get:
->
So it's not my regular linux prompt and it's not the mysql prompt after logging in, which is mysql>
I don't get/see any errors just that crappy little prompt. I have to "ctrl-c" to get out, otherwise, nothing I enter after that prompt does squat. I haven't found anything on this. Can someone who is more versed in msyql/SQL point me in the right direction?
Thanks
You need to end each statement with a semi-colon (;).
create database october24;
That prompt is because MySQL doesn't know you were done with your query and is expecting more input.
You're missing a semi-colon. Type it, press enter and then the prompt will be back :)
EG:
mysql> select id, max(name)
-> from table
-> group by id;

Executing Line/Multiple Lines Only in mySQL Query Browser

I already used Microsoft SQL Server 2005 and found really easy to execute single/multiple lines of an sql query.
Example:
insert into tablea
($vala, $valb, $valc)
values
($vala, $valb, $valc);
insert into tableb
($vala, $valb, $valc)
values
($vala, $valb, $valc);
How can I execute the second part only? In MSSQL i will highlight the second insert statment and press F5. How can do this in mySQL?
The problem is that you must be trying to execute your query from a Query Tab rather than from a Script Tab. Go to File -> New Script Tab and input your multiple statements there. Next click the execute button... that's it.
Hope it helps!
Machi
You can do this. When you have logged into MySQL query browser, and you write two complete statments such as:
select "hello world";
select "second query";
You will notice two blue dots on the left side of the window they are left of the line numbers. By default it will try to exec the first command. That might be why you see one command with white background and all the others with a grey background. The command that is white, is highlighted and it is the one that will be executed. You should be able to just click anywhere inside the second query to highlight it and then click the lightning bolt button (execute) to run it.
You can do this in MySQL, but you have to use mysqli. Click here for details:
http://php.net/manual/en/mysqli.quickstart.multiple-statement.php
In workbench, make sure the cursor is in the statement you want to execute and hit Ctrl+Enter.
Ctrl+Shift+Enter will run all statements consecutively in the window/document.
In addition if you have selected a statement, Ctrl+Shift+Enter will execute the selected statement only.
Does selecting the second part and "EXECUTE" help? If not, then I am not sure if such a use case is supported. You might want to try MySQL Workbench though.
well the issue here is that if i write the queries :
select "hello world";
select "second query";
and Execute it gives error -- when i select/highlight any one of them and execute it gives the same error -- so i have to either delete one of the queries or comment it out or use the script editor which doesn't work for me and lot of other users who have use MS SQL 2000,2005.
If there a solution for this -- ideally it should execute the query i select .
Just an opinion
Rohan

How to make a field NULL using MySQL GUI Tools?

I'm using the MySQL Query Browser (part of the MySQL GUI Tools) and need to change a field to NULL, but I can't figure out how to do it - if I delete the value it tries to update it to ''. Typing "NULL" makes it try to update to 'NULL' (a string).
I know I could just write a query to do it, but that defeats the entire purpose of the tool, no?
In MySQL Query Browser, right click on the cell and select 'Clear field content' while the focus is in another cell.
In MySQL Workbench, right click on the cell and select 'Set Field to NULL'.
In MySQL Workbench, with the cell selected, press Shift + Delete
Tested on 6.3.4.0
Right-click on that column and select the
'Set field to Null'
option from the context menu.
Removing the contents:
This works for some tools (sorry to hear it doesn't for yours).
This may not appear as null but will when you perform a query.
Shift + Delete
work well in MySql Workbench 8
I'd try Ctrl-0 (zero), because that works in some tools.