Query with values ​​added by ampersand - works in Oracle, but not in MySQL?

In MySQL, the description below works:

mysql>insert into emp1(empno,empname,empsal,empcity) values (100,'vinay',10000,'USA');** mysql> select * from emp1; +-------+---------+--------+---------+ | empno | empname | empsal | empcity | +-------+---------+--------+---------+ | 100 | vinay | 10000 | USA | +-------+---------+--------+---------+ 

In Oracle, the description below works:

 mysql> insert into emp1 values(&empno,'&empname',&empsal,'&empcity');** 

But this does not work in MySQL - why not add & values?

+7
database oracle mysql
source share
3 answers

Similar code for MySQL is as follows:

 SET @empno = 100, @empname = 'vinay', @empsal = 10000, @empcity = 'USA'; insert into emp1 values(@empno,@empname,@empsal,@empcity); 

Pay attention to @ , no ' in INSERT values, etc.

If you are moving the system between different DBMSs, you must plan for a significant rewrite. This is just one of hundreds of differences between Oracle and MySQL.

+5
source share

Suppose ampersands are for SQL * Plus replacement variables .

They are supported by Oracle, but not MySQL.

+6
source share

'&' is supported in Oracle, but not in MySQL, why it gives a compilation error in MySQL.

+1
source share

All Articles