satimis Posted May 22, 2009 Share Posted May 22, 2009 Hi folks,Ran following command to create aliases table mysql> CREATE TABLE `aliases` ( -> `pkid` smallint(3) NOT NULL auto_increment, -> `mail` varchar(120) NOT NULL default '', -> `destination` varchar(120) NOT NULL default '', -> `enabled` tinyint(1) NOT NULL default '1', -> PRIMARY KEY (`pkid`), -> UNIQUE KEY `mail` (`mail`) -> );Query OK, 0 rows affected (0.01 sec) And ran following command to enter data mysql> INSERT INTO aliases (mail,destination) VALUES -> ('albert@abc.com','albert@abc.com'), Now I need to change "albert@abc.com" to "albertlee@abc.com" running following command without sucess mysql> ALTER aliases CHANGE 'albert@abc.com', 'albertcheung@abc.com' varchar(120);mysql> ALTER aliases CHANGE 'albert@abc.com' 'albertcheung@abc.com';mysql> ALTER aliases CHANGE 'albert@abc.com', 'albertcheung@abc.com'; etc. Always syntax error.Please advise what will be the correct syntax? TIAWill MODIDY be the same as CHANGE?Can I use DROP to erase this email address? If YES please advise how? B.R.satimis Link to comment Share on other sites More sharing options...
justsomeguy Posted May 22, 2009 Share Posted May 22, 2009 SQL is split up into two types of statements, there are data definition statements and data manipulation statements. Definition statements are used for creating the tables, changing the field properties, etc, changing the actual structure of the database. Manipulation statements are for working with the actual data instead of the structure. ALTER TABLE is a data definition statement. INSERT is a manipulation statement. If you want to update data that is already there, you need to use an UPDATE statement, not ALTER. If you use DROP TABLE it will delete the entire table, not just the data. If you want to delete data you use DELETE.http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.