Jump to content

Typing Mistake


satimis

Recommended Posts

Hi folks,I made a typing mistake "neme" on following table;mysql> DESCRIBE virtual_domains;

+-------+-------------+------+-----+---------+----------------+| Field | Type		| Null | Key | Default | Extra		  |+-------+-------------+------+-----+---------+----------------+| id	| int(11)	 | NO   | PRI | NULL	| auto_increment || neme  | varchar(50) | NO   |	 |		 |				|+-------+-------------+------+-----+---------+----------------+2 rows in set (0.00 sec)

Please advise how can I correct it instead of drop the table. TIAB.R.satimis

Link to comment
Share on other sites

alter table virtual_domains change neme name varchar(50)

Hi Stefano De Boni',Your advice works here. ThanksBefore reading your posting I tried following commands;mysql> ALTER TABLE virtual_domains -> CHANGE [COLUMN] neme name;
ERROR 1064 (42000): 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 '[COLUMN] neme name' at line 2

mysql> ALTER TABLE virtual_domains -> CHANGE [COLUMN] 'neme' 'name';

ERROR 1064 (42000): 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 '[COLUMN] 'neme' 'name'' at line 2

mysql> ALTER TABLE virtual_domains -> CHANGE [COLUMN] neme name Field;

ERROR 1064 (42000): 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 '[COLUMN] neme name Field' at line 2

mysql> ALTER TABLE virtual_domains -> CHANGE [COLUMN] 'neme' 'name' 'Field';

ERROR 1064 (42000): 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 '[COLUMN] 'neme' 'name' 'Field'' at line 2

I can't resolve "column_definition". "varchar(50)" ? "No Null"?I read following manual;http://dev.mysql.com/doc/refman/5.0/en/alter-table.htmlplus some others found on googling. But the syntax confuses me.What is column_definition?What is {INDEX|KEY} [index_name], reference_definition, reference_definition, etc.They confuse me to certain extent. Also the error on the commands run by me previously always asking looking for the right version of MySQL.Are there MySQL documents with examples illustrated? TIAB.R.satimis

Link to comment
Share on other sites

since you've already renamed the column what you need now is:alter table virtual_domains modify name varchar(50) not null;the complete script would have beenalter virtual_domains change neme name varchar(50) not null;words between brackets are just comments they mustn't be included in the command.Unfortunatly I've never found such documentation with examples in about MySQL, my suggestion is to learn how to read them. It's much better to to learn how read the documentation before learning the code itself. Once you understand them you won't need to google arund to find out the exact sample fitting your request. Any way consider you're luky, at least you're english speaking, often you can't find documentation written in other laguages. Think about reading japanese MySQL reference.....regards

Link to comment
Share on other sites

since you've already renamed the column what you need now is:alter table virtual_domains modify name varchar(50) not null;
mysql> DESCRIBE virtual_domains;
+-------+-------------+------+-----+---------+----------------+| Field | Type		| Null | Key | Default | Extra		  |+-------+-------------+------+-----+---------+----------------+| id	| int(11)	 | NO   | PRI | NULL	| auto_increment || name  | varchar(50) | YES  |	 | NULL	|				|+-------+-------------+------+-----+---------+----------------+2 rows in set (0.00 sec)

mysql> ALTER TABLE virtual_domains	-> MODIFY name varchar(50) not null;Query OK, 0 rows affected (0.12 sec)Records: 0  Duplicates: 0  Warnings: 0

mysql> DESCRIBE virtual_domains;

+-------+-------------+------+-----+---------+----------------+| Field | Type		| Null | Key | Default | Extra		  |+-------+-------------+------+-----+---------+----------------+| id	| int(11)	 | NO   | PRI | NULL	| auto_increment || name  | varchar(50) | NO   |	 |		 |				|+-------+-------------+------+-----+---------+----------------+2 rows in set (0.00 sec)

the complete script would have beenalter virtual_domains change neme name varchar(50) not null;
Noted with thanks.
words between brackets are just comments they mustn't be included in the command.
Noted and thanksB.R.satimis
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...