Re: Rename a columkn
- Original Message - From: "Paul DuBois" <[EMAIL PROTECTED]> To: "Rhino" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; "leegold" <[EMAIL PROTECTED]> Sent: Wednesday, September 08, 2004 7:29 PM Subject: Re: Rename a columkn > At 18:02 -0400 9/8/04, Rhino wrote: > >- Original Message - > >From: "leegold" <[EMAIL PROTECTED]> > >To: <[EMAIL PROTECTED]> > >Sent: Wednesday, September 08, 2004 5:31 PM > >Subject: Rename a columkn > > > > > >> I sent a previous email w/the wrong subj. - sorry. > >> > >> The example below renames a col. But can I rename a col. w/out giving > >> all that type spec. at the end of the statement below. I just want to > >> rename, everything else stays the same. Thanks. > >> > >> mysql> ALTER TABLE search CHANGE Description PageDescription > >> VARCHAR(255) NOT NULL; > >> > >Have you tried looking in the manual? > > > >According to http://dev.mysql.com/doc/mysql/en/ALTER_TABLE.html, you can > >rename a column by including the old name, the new name AND the datatype. > >The example they give is: > > > >mysql> ALTER TABLE t1 CHANGE a b INTEGER; > > > >So, you have to supply the datatype but you can apparently omit the null > >specification. In your case, I assume you would have to include > >'VARCHAR(255)', not just 'VARCHAR', but I could be wrong; the manual doesn't > >say explicitly. > > The syntax is: > > CHANGE [COLUMN] old_col_name column_definition [FIRST|AFTER col_name] > > column_definition includes the column attributes (NULL, NOT NULL, DEFAULT, > etc.) > > > > >In any case, it is very easy to try the command on a test table just to see > >what MySQL allows or prohibits. > > My mistake. I saw the example and it didn't include a null specification so I assumed you could omit it for the column rename. Apparently, there was no null specification in the first place (so that nulls would be permitted in the column), which is why the example omitted it. Sorry for any confusion I caused. Rhino -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Rename a columkn
At 18:02 -0400 9/8/04, Rhino wrote: - Original Message - From: "leegold" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 08, 2004 5:31 PM Subject: Rename a columkn I sent a previous email w/the wrong subj. - sorry. The example below renames a col. But can I rename a col. w/out giving all that type spec. at the end of the statement below. I just want to rename, everything else stays the same. Thanks. mysql> ALTER TABLE search CHANGE Description PageDescription VARCHAR(255) NOT NULL; Have you tried looking in the manual? According to http://dev.mysql.com/doc/mysql/en/ALTER_TABLE.html, you can rename a column by including the old name, the new name AND the datatype. The example they give is: mysql> ALTER TABLE t1 CHANGE a b INTEGER; So, you have to supply the datatype but you can apparently omit the null specification. In your case, I assume you would have to include 'VARCHAR(255)', not just 'VARCHAR', but I could be wrong; the manual doesn't say explicitly. The syntax is: CHANGE [COLUMN] old_col_name column_definition [FIRST|AFTER col_name] column_definition includes the column attributes (NULL, NOT NULL, DEFAULT, etc.) In any case, it is very easy to try the command on a test table just to see what MySQL allows or prohibits. Rhino -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Rename a columkn
- Original Message - From: "leegold" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 08, 2004 5:31 PM Subject: Rename a columkn > I sent a previous email w/the wrong subj. - sorry. > > The example below renames a col. But can I rename a col. w/out giving > all that type spec. at the end of the statement below. I just want to > rename, everything else stays the same. Thanks. > > mysql> ALTER TABLE search CHANGE Description PageDescription > VARCHAR(255) NOT NULL; > Have you tried looking in the manual? According to http://dev.mysql.com/doc/mysql/en/ALTER_TABLE.html, you can rename a column by including the old name, the new name AND the datatype. The example they give is: mysql> ALTER TABLE t1 CHANGE a b INTEGER; So, you have to supply the datatype but you can apparently omit the null specification. In your case, I assume you would have to include 'VARCHAR(255)', not just 'VARCHAR', but I could be wrong; the manual doesn't say explicitly. In any case, it is very easy to try the command on a test table just to see what MySQL allows or prohibits. Rhino -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Rename a columkn
I sent a previous email w/the wrong subj. - sorry. The example below renames a col. But can I rename a col. w/out giving all that type spec. at the end of the statement below. I just want to rename, everything else stays the same. Thanks. mysql> ALTER TABLE search CHANGE Description PageDescription VARCHAR(255) NOT NULL; -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]