forums › forums › SQLyog › Using SQLyog › Drop And Create Table – New Mysql User
- This topic is empty.
-
AuthorPosts
-
-
December 29, 2005 at 5:19 pm #9422rtkMember
When I try and create a table that already exists I get “Error Code : 1050
Table 'products' already exists”.
Is there a way to create the table and force it to overwrite if the table already exists?
I've tried this series in my query
DROP TABLE PRODUCTS
CREATE TABLE PRODUCTS
SELECT …
but I get…
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE PRODUCTS
Thanks
Russ
-
December 29, 2005 at 5:39 pm #20144peterlaursenParticipantQuote:I've tried this series in my query
DROP TABLE PRODUCTS
CREATE TABLE PRODUCTS
SELECT …
First: If you have more queries they should be divided with “;” (semicolon)
Next: A new table must have at least one column. You could write then (just an example):
Quote:drop table products;create table products (`id` bigint NOT NULL AUTO_INCREMENT , `t` varchar (50) NULL , PRIMARY KEY ( `id` ) );
select ….
But why don't you use the GUI ?
1) Right.click a table .. choose 'drop table'
2) Right-click a database .. choose 'create table' SQLyog then generates the SQL needed. You can view it in HISTORY-pane
-
December 29, 2005 at 5:41 pm #20145peterlaursenParticipant
Besides ..
You can also ALTER TABLE …
Then existing data are kept (unless you drop the column)
-
December 29, 2005 at 5:49 pm #20146rtkMember
I'm using the SELECT statement to create the data.
I don't want to use the GUI because what I want to happen without user input at night is this…
1/Import my ODBC tables automatically (figured this out)
2/Create a table using a select statement automatically (almost there except for this problem)
3/Export the new table to my website MYSQL server.
If I seperate the drop table statment from my create table statement with a ';' it stops the query after the “drop table” and does not create the new table from the following select statement.
If I run the drop table statement and the create table select… individually in separate queries they work fine.
?
-
December 29, 2005 at 5:56 pm #20147peterlaursenParticipantQuote:If I seperate the drop table statment from my create table statement with a ';' it stops the query after the “drop table” and does not create the new table from the following select statement.
Ok – there are two possibilities:
1) to execute 'current query' (single arrow icon or keyboard shortcut: F5)
2) to execute 'all queries' (double arrow icon or keyboard shortcut: Shift + F5)
Check program help .. keyboard shortcuts
-
-
AuthorPosts
- You must be logged in to reply to this topic.