What does it mean when the console displays ->? - mysql

Rookie question.
I was performing some mysql processes, and then the console displays an indented -> as in the image below, instead of the normal console prompt:
What does that mean? I can't do anything with it there.
Thank you!

Means that the sentence is not completed.
To end a sentence inside a mysql session, you have to type ;⏎.
By the way, you couldn't do a cat inside a mysql session.

Related

MYSQL codes not being read

When I input a code or anything into MySQL and hit "enter" it moves down and "->" appears. It is as if the code is not going through or the code is not being read.
I have attempted to download "add-ons" but I am really not sure what I am doing. This is for school and I am having trouble getting in touch with the professor.
I am new to this and can't figure out what I am doing wrong. Please help!
Please see image of what it looks like to me.
Please add semicolon ; after the mysql code.
Problem 1: Be aware of the prompt. Either of these
MariaDB >
mysql >
means that you are inside the MySQL commandline tool. You can enter only SQL statements. Most SQL queries need to be terminated by a ; or \G (but not both). To exit that tool:
exit
Or, if you get stuck in certain ways
CTRL-C
exit
Each of these implies a shell script:
$
#
mymachine$
/usr/home/rj $
C:\Users\rj:
and many others
Problem 2: mysqldump is a command, not SQL. So it needs to be executed in a shell script.
Problem 3: There is yet another problem. When it suggested typing 'help;', it did not mean for you to include the quotes. Instead, type just help;.

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;

How to undo sql USE?

What's the SQL command to undo:
USE db;
The syntax I see everywhere is:
USE [db] ;
implying that I can leave out the db part. Not so - this is a syntax error however (maybe just syntax errors in the SQL syntax syntax?).
edit
The programming problem this is causing is that I can't reset the environment in which subsequent commands run. I could reset my DB connection, but this seems efficient.
cmdX; // Works
vs.
cmdX;
cmdY; // May fail because command X upset some state.
cmdX should clean up after itself and put things back where it found them.
Analogously:
cd ./a
doX()
cd ../
doY() // Y expects to not be in a?
I don't think you can. The documentation doesn't say the parameter is optional. It says:
The database remains the default until the end of the session or another USE statement is issued:
So if you want to drop the default, end your session and start a new one without selecting a DB.
What programming problem is this causing for you?
The database argument is not optional.
mysql> use
ERROR:
USE must be followed by a database name
I'm not sure where you saw this command with square brackets around the argument. That is not shown at the documentation page: http://dev.mysql.com/doc/refman/5.6/en/use.html
Microsoft SQL Server uses square brackets around identifiers (as opposed to a style to indicate an optional argument), but the MS SQL documentation for USE also doesn't show it: http://msdn.microsoft.com/en-us/library/ms188366.aspx
What would it mean to "undo" a USE command? Would it be like cd - in bash, making the previous default database again the default? There is no such command in MySQL for this. It doesn't remember what was your previous default database. If you want to return, you just have to USE that database and name it explicitly.

Is it possible to perform a MySQL query using Phing and set the value as a property?

I'm new to Phing.
I'd like to query a value in a MySQL database table, and have the value set as a property so that I can echo it out nicely to the screen.
I can see that there is a PDOSQLExecTask which would allow me to run some SQL, but I can't see how to set the returned value into a property?
The query I want to run is:
SELECT MAX(change_number)
FROM changelog;
I'd like it set into a property:
Can anyone shed any light please?
Thanks,
Chris
I have access to MySQL at command line, I went with the following solution. I'm sure it's not the best, if someone else can improve it please do!
<!-- What's the latest delta that's been applied to this deployment? -->
<exec
command="${progs.mysql} -h${db.host} -u${db.user} -p${db.pass} -e 'USE ${db.main_db}; SELECT MAX(`change_number`) FROM `changelog`;'"
dir="."
checkreturn="false"
passthru="false"
outputProperty="latest_version_output"
/>
<php expression="preg_replace('/[^0-9]|\r|\n/si', '', '${latest_version_output}');" returnProperty="latest_version_applied" />
<echo msg="Latest delta applied was: ${latest_version_applied}" />
The PDOSQLExecTask comes with two default formatters, which will send their output to a file. To change this, you'd probably have to implement your own formatter. On the other hand, the task appears to read its SQL commands from a separate file with SQL commands, not the build file.
So on the whole, It seems to me like you might be better of writing your own task, probably using some code from the implementation of PDOSQLExecTask but with your own command input and result output. Unless calling the mysql command line binary is an alternative for you, in which case you could wrap up that call to redirect its output to a property using the outputProperty attribute to the ExecTask.

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