-2

I have a table:

    CREATE TABLE IF NOT EXISTS `agents` (
    `idx` int(11) NOT NULL AUTO_INCREMENT,
    `newConfig` tinyint(1) NOT NULL DEFAULT '0',
    `agent_id` char(20) NOT NULL,
    `time` int(11) NOT NULL,
    `status` varchar(15) NOT NULL,
    `agent_ip` char(15) NOT NULL,
    `FilterExpression` varchar(1024) NOT NULL,
    `agent_alias` char(128) NOT NULL,
    `agent_type` char(128) NOT NULL,
    `ATMSIP` varchar(15) NOT NULL,
    `ATMSPort` varchar(5) NOT NULL,
    `MaxHeadersLength` varchar(10) NOT NULL,
    `MaxGetParamsLength` varchar(10) NOT NULL,
    `MaxPostLength` varchar(10) NOT NULL,
    `StatusInterval` int(11) NOT NULL,
    `CookieExpireTime` int(11) NOT NULL,
    `ConcurrentSessions` varchar(10) NOT NULL,
    `MessagesQueueSize` varchar(10) NOT NULL,
    `owner_user` char(20) NOT NULL,
    `owner_group` char(20) NOT NULL,
    `msg_id` bigint(20) NOT NULL,
    `NetworkInterface` char(64) NOT NULL,
    `fingerprint_headers` varchar(4096) NOT NULL,
    PRIMARY KEY (`idx`),
    UNIQUE KEY `agent_id` (`agent_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

Now I want to verify that index agent_id was added(in case the table exists already and thus was not created) by doing :

if not exists ( SELECT INDEX_NAME FROM INFORMATION_SCHEMA.STATISTICS WHERE
        `TABLE_SCHEMA` = 'Telepath-NewSchema' AND
        `TABLE_NAME` = `agents` AND `INDEX_NAME` = `agent_id`)
    then 
        ALTER IGNORE TABLE `agents` ADD UNIQUE `agent_id` (`agent_id`);
end if;

but when I run the script I get: Unknown column 'agents' in 'where clause'

Why does it think that agents is a column??

Thanks

4

1 回答 1

1

`agents`应该是'agents'。对于'agent_id'.

于 2013-06-03T10:04:29.760 回答