Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot insert into table because the table already exists?

Tags:

sybase

I have a user table. I want to insert data into my user table.

I have a statement:

SELECT columna, columnb, 
INTO my_table 
FROM my_other_table
WHERE (... conditions ...)

I get the following error:

SQL Server Error on (myserver) Error:2714 at Line:1 Message:There is already an object named 'my_table' in the database.

Yes, thanks Sybase. I know this. I know the table exists. I want to insert data into it.

Why is Sybase not playing nicely? :(

(Sybase isn't my forte, Oracle is. This may just be an understanding issue, or lack there of. This would never happen in Oracle...)

like image 660
glasnt Avatar asked Jun 18 '09 00:06

glasnt


People also ask

How to insert VALUES IN MySQL 8. 0?

INSERT INTO tbl_name () VALUES(); If strict mode is not enabled, MySQL uses the implicit default value for any column that has no explicitly defined default. If strict mode is enabled, an error occurs if any column has no default value. Use the keyword DEFAULT to set a column explicitly to its default value.

How to insert data into a table IN MySQL?

In syntax, First, you must specify the name of the table. After that, in parenthesis, you must specify the column name of the table, and columns must be separated by a comma. The values that you want to insert must be inside the parenthesis, and it must be followed by the VALUES clause.

How do you insert a new record in a table if not exists?

There are three ways you can perform an “insert if not exists” query in MySQL: Using the INSERT IGNORE statement. Using the ON DUPLICATE KEY UPDATE clause. Or using the REPLACE statement.

How to insert VALUES into table IN MySQL command line?

When inserting a single row into the MySQL table, the syntax is as follows: INSERT INTO table_name(column_1,column_2,column_3) VALUES (value_1,value_2,value_3); In the INSERT INTO query, you should specify the following information: table_name : A MySQL table to which you want to add a new row.


1 Answers

SELECT ... INTO is for creating new tables.

Use INSERT ... SELECT for existing tables. eg:

INSERT INTO my_table 
SELECT columna, columnb, 
FROM my_other_table
WHERE (... conditions ...)
like image 157
Peter Radocchia Avatar answered Sep 30 '22 17:09

Peter Radocchia