I am trying to create a table (nightly routine) and then insert table data from another table. Right now I get that the table already exists. Not sure the syntax I should be using here.
[Err] 1050 - Table 'testgiver.safewp_users' already exists
DROP TABLE
IF EXISTS testgiver.safewp_users;
CREATE TABLE `testgiver.safewp_users` (
`ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_login` varchar(60) NOT NULL DEFAULT '',
`user_pass` varchar(64) DEFAULT '',
`user_nicename` varchar(50) NOT NULL DEFAULT '',
`user_email` varchar(100) NOT NULL DEFAULT '',
`user_url` varchar(100) DEFAULT '',
`user_registered` datetime NOT NULL DEFAULT '2014-01-01 10:00:00',
`user_activation_key` varchar(60) NOT NULL DEFAULT '',
`user_status` int(11) NOT NULL DEFAULT '0',
`display_name` varchar(250) NOT NULL DEFAULT '',
PRIMARY KEY (`ID`),
KEY `user_login_key` (`user_login`),
KEY `user_nicename` (`user_nicename`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
INSERT INTO safewp_users (`user_login`, `user_nicename`, `user_email`, `display_name`)
SELECT
ldap_full.uid,
ldap_full.sn,
ldap_full.mail,
ldap_full.cn
FROM
ldap_full
This looks like a simple typo.
CREATE TABLE `testgiver.safewp_users`
should probably read
CREATE TABLE `testgiver`.`safewp_users`
Otherwise, you are attempting to create a table called 'testgiver.safewp_users'
every single time.
Get rid of the quotes in your create table statement. The quotes are causing you to attempt to create a table named testgiver.safewp_users in the default schema, instead of a table named safewp_users in the testgiver schema.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.