Adding Fields To Table

Adding Fields To Table

am 30.09.2009 18:45:49 von Carlos Williams

I am no doubt very new to MySQL and have been studying the on line
manual however I find it a bit complex and don't understand what it's
suggesting I do in this case. I created a database called 'staff' and
then in that database I created one simple table:

mysql> show tables;
+-----------------+
| Tables_in_staff |
+-----------------+
| it |
+-----------------+
1 row in set (0.00 sec)

mysql> describe it;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| name | varchar(40) | YES | | NULL | |
| username | varchar(20) | YES | | NULL | |
| email | varchar(20) | YES | | NULL | |
| office | char(3) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

My question is if I would like to add addition fields like 'title' &
'phone number', how can I modify the table fields entry to add more
fields? Thanks for any help!

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Adding Fields To Table

am 30.09.2009 18:51:34 von joao

alter table it add title varchar(50);

"Carlos Williams" escreveu na mensagem
news:d80f793f0909300945n73394480j468c2cf76dc9c7d8@mail.gmail .com...
>I am no doubt very new to MySQL and have been studying the on line
> manual however I find it a bit complex and don't understand what it's
> suggesting I do in this case. I created a database called 'staff' and
> then in that database I created one simple table:
>
> mysql> show tables;
> +-----------------+
> | Tables_in_staff |
> +-----------------+
> | it |
> +-----------------+
> 1 row in set (0.00 sec)
>
> mysql> describe it;
> +----------+-------------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +----------+-------------+------+-----+---------+-------+
> | name | varchar(40) | YES | | NULL | |
> | username | varchar(20) | YES | | NULL | |
> | email | varchar(20) | YES | | NULL | |
> | office | char(3) | YES | | NULL | |
> +----------+-------------+------+-----+---------+-------+
> 4 rows in set (0.00 sec)
>
> My question is if I would like to add addition fields like 'title' &
> 'phone number', how can I modify the table fields entry to add more
> fields? Thanks for any help!



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Adding Fields To Table

am 30.09.2009 19:11:42 von mos

Carlos,
Get a free copy of SqlYog (Community edition).
http://code.google.com/p/sqlyog/

Mike

At 11:45 AM 9/30/2009, you wrote:
>I am no doubt very new to MySQL and have been studying the on line
>manual however I find it a bit complex and don't understand what it's
>suggesting I do in this case. I created a database called 'staff' and
>then in that database I created one simple table:
>
>mysql> show tables;
>+-----------------+
>| Tables_in_staff |
>+-----------------+
>| it |
>+-----------------+
>1 row in set (0.00 sec)
>
>mysql> describe it;
>+----------+-------------+------+-----+---------+-------+
>| Field | Type | Null | Key | Default | Extra |
>+----------+-------------+------+-----+---------+-------+
>| name | varchar(40) | YES | | NULL | |
>| username | varchar(20) | YES | | NULL | |
>| email | varchar(20) | YES | | NULL | |
>| office | char(3) | YES | | NULL | |
>+----------+-------------+------+-----+---------+-------+
>4 rows in set (0.00 sec)
>
>My question is if I would like to add addition fields like 'title' &
>'phone number', how can I modify the table fields entry to add more
>fields? Thanks for any help!
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe: http://lists.mysql.com/mysql?unsub=mos99@fastmail.fm


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Adding Fields To Table

am 30.09.2009 19:28:09 von Carlos Williams

On Wed, Sep 30, 2009 at 1:11 PM, mos wrote:
> Carlos,
>    Get a free copy of SqlYog (Community edition).
> http://code.google.com/p/sqlyog/

Thanks but I don't have any GUI's installed on my machine I manage the
database on or from. I am also trying to learn in case things break
and I only have access to CLI.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: Adding Fields To Table

am 30.09.2009 21:34:10 von Robert Citek

If you are very new, you may want to go through the tutorial at w3shools:

http://www.w3schools.com/SQl/default.asp

Regards,
- Robert

On Wed, Sep 30, 2009 at 11:45 AM, Carlos Williams wrote:
> I am no doubt very new to MySQL and have been studying the on line
> manual however I find it a bit complex and don't understand what it's
> suggesting I do in this case.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Adding Fields To Table

am 01.10.2009 09:02:34 von Martijn Tonies

Hello Carlos,

>I am no doubt very new to MySQL and have been studying the on line
> manual however I find it a bit complex and don't understand what it's
> suggesting I do in this case. I created a database called 'staff' and
> then in that database I created one simple table:
>
> mysql> show tables;
> +-----------------+
> | Tables_in_staff |
> +-----------------+
> | it |
> +-----------------+
> 1 row in set (0.00 sec)
>
> mysql> describe it;
> +----------+-------------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +----------+-------------+------+-----+---------+-------+
> | name | varchar(40) | YES | | NULL | |
> | username | varchar(20) | YES | | NULL | |
> | email | varchar(20) | YES | | NULL | |
> | office | char(3) | YES | | NULL | |
> +----------+-------------+------+-----+---------+-------+
> 4 rows in set (0.00 sec)
>
> My question is if I would like to add addition fields like 'title' &
> 'phone number', how can I modify the table fields entry to add more
> fields? Thanks for any help!

The manual has a section on how to create and modify your metadata,
I suggest you take a look, it explains all.

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Adding Fields To Table

am 01.10.2009 09:24:55 von prabhat kumar

--001636417d5f50daf60474da8b20
Content-Type: text/plain; charset=ISO-8859-1

You can use :

*ALTER TABLE it ADD COLUMN title varchar(25), phone number integer (6);*

it will add new column after last.

but you can also specify the particular column after you want to add.

like.

*ALTER TABLE it ADD COLUMN title varchar(25), phone number integer (6) AFTER
pusername; *

check more options.
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

On Thu, Oct 1, 2009 at 12:32 PM, Martijn Tonies wrote:

> Hello Carlos,
>
> I am no doubt very new to MySQL and have been studying the on line
>> manual however I find it a bit complex and don't understand what it's
>> suggesting I do in this case. I created a database called 'staff' and
>> then in that database I created one simple table:
>>
>> mysql> show tables;
>> +-----------------+
>> | Tables_in_staff |
>> +-----------------+
>> | it |
>> +-----------------+
>> 1 row in set (0.00 sec)
>>
>> mysql> describe it;
>> +----------+-------------+------+-----+---------+-------+
>> | Field | Type | Null | Key | Default | Extra |
>> +----------+-------------+------+-----+---------+-------+
>> | name | varchar(40) | YES | | NULL | |
>> | username | varchar(20) | YES | | NULL | |
>> | email | varchar(20) | YES | | NULL | |
>> | office | char(3) | YES | | NULL | |
>> +----------+-------------+------+-----+---------+-------+
>> 4 rows in set (0.00 sec)
>>
>> My question is if I would like to add addition fields like 'title' &
>> 'phone number', how can I modify the table fields entry to add more
>> fields? Thanks for any help!
>>
>
> The manual has a section on how to create and modify your metadata,
> I suggest you take a look, it explains all.
>
> With regards,
>
> Martijn Tonies
> Upscene Productions
> http://www.upscene.com
>
> Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
> Anywhere, MySQL, InterBase, NexusDB and Firebird!
>
> Database questions? Check the forum:
> http://www.databasedevelopmentforum.com
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=aim.prabhat@gmail.com
>
>


--
Best Regards,

Prabhat Kumar
MySQL DBA
Datavail-India Mumbai
Mobile : 91-9987681929
www.datavail.com

My Blog: http://adminlinux.blogspot.com
My LinkedIn: http://www.linkedin.com/in/profileprabhat

--001636417d5f50daf60474da8b20--

Re: Adding Fields To Table

am 01.10.2009 11:10:11 von Joerg Bruehe

Hi!


prabhat kumar wrote:
> You can use :
>=20
> *ALTER TABLE it ADD COLUMN title varchar(25), phone number integer =
(6);*
>=20
> it will add new column after last.
>=20
> but you can also specify the particular column after you want to ad=
d.
>=20
> like.
>=20
> *ALTER TABLE it ADD COLUMN title varchar(25), phone number integer =
(6) AFTER
> pusername; *

The syntax is correct, but one data type is wrong:

A phone number is no numeric type, it is a string of (mostly) digits.

Those who think there is no difference, they are wrong:
1) In a phone number, you may need a leading zero. No numeric type
supports that, unless you try some formatting which would then aff=
ect
all values and not just selected ones.
2) Just ask yourself whether it makes sense to compute the average ph=
one
number (yes, the term is misleading).

Similar reasoning applies to other digit strings, like article number=
,
ISBN (books), SSN (social security number), passport number, etc.


Jörg

--=20
Joerg Bruehe, MySQL Build Team, Joerg.Bruehe@Sun.COM
Sun Microsystems GmbH, Komturstraße 18a, D-12099 Berlin
Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Haering Muenchen: HRB1610=
28


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: Adding Fields To Table

am 01.10.2009 11:31:34 von prabhat kumar

--000e0cd6a7ba3d998d0474dc504b
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Thanks Joerg. You are very correct.

On Thu, Oct 1, 2009 at 2:40 PM, Joerg Bruehe wrote:

> Hi!
>
>
> prabhat kumar wrote:
> > You can use :
> >
> > *ALTER TABLE it ADD COLUMN title varchar(25), phone number integer (6);=
*
> >
> > it will add new column after last.
> >
> > but you can also specify the particular column after you want to add.
> >
> > like.
> >
> > *ALTER TABLE it ADD COLUMN title varchar(25), phone number integer (6)
> AFTER
> > pusername; *
>
> The syntax is correct, but one data type is wrong:
>
> A phone number is no numeric type, it is a string of (mostly) digits.
>
> Those who think there is no difference, they are wrong:
> 1) In a phone number, you may need a leading zero. No numeric type
> supports that, unless you try some formatting which would then affect
> all values and not just selected ones.
> 2) Just ask yourself whether it makes sense to compute the average phone
> number (yes, the term is misleading).
>
> Similar reasoning applies to other digit strings, like article number,
> ISBN (books), SSN (social security number), passport number, etc.
>
>
> Jörg
>
> --
> Joerg Bruehe, MySQL Build Team, Joerg.Bruehe@Sun.COM
> Sun Microsystems GmbH, Komturstraße 18a, D-12099 Berlin
> Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
> Vorsitzender des Aufsichtsrates: Martin Haering Muenchen: HRB161028
>
>


--=20
Best Regards,

Prabhat Kumar
MySQL DBA
Datavail-India Mumbai
Mobile : 91-9987681929
www.datavail.com

My Blog: http://adminlinux.blogspot.com
My LinkedIn: http://www.linkedin.com/in/profileprabhat

--000e0cd6a7ba3d998d0474dc504b--