Unix Technical Forum

How to change field size using SQL against an oracle Database

This is a discussion on How to change field size using SQL against an oracle Database within the Oracle Miscellaneous forums, part of the Oracle Database category; --> I open up Oracle SQL*Plus and i want to change the field size for one of my columns in ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 11:57 AM
BookerT
 
Posts: n/a
Default How to change field size using SQL against an oracle Database

I open up Oracle SQL*Plus and i want to change the field size for one
of my columns in one of my databases. I have a generic SQL book, but
when I try some of the commands, they don't seem to work in SQL*PLUS

How can I perform this procedure on a table called INQUIRIES within my
database. I want to change the field size from 10 , to say , 60

I even wanted to jus ttry the EXPLAIN command to view the table, but
when I type EXPLAIN INQUIRIES, i get a missing keyword error.




Thanks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 11:57 AM
Malcolm Dew-Jones
 
Posts: n/a
Default Re: How to change field size using SQL against an oracle Database

BookerT (chipw@ascac.org) wrote:
: I open up Oracle SQL*Plus and i want to change the field size for one
: of my columns in one of my databases. I have a generic SQL book, but
: when I try some of the commands, they don't seem to work in SQL*PLUS

: How can I perform this procedure on a table called INQUIRIES within my
: database. I want to change the field size from 10 , to say , 60

In sqlplus, the COLUMN command controls the width and etc of the display
of each column. The COlumn command is specific to the sqlplus tool, it is
a thing quite apart from the SQL language.

google: sqlplus reference
google: sqlplus faq

: I even wanted to jus ttry the EXPLAIN command to view the table, but
: when I type EXPLAIN INQUIRIES, i get a missing keyword error.

You are guessing on this one.

The command you likely want is DESCRIBE, which can be used within SQLPLUS
to show the layout of many objects, including tables and views. (And
again it is a command that is not part of SQL).

To view the _contents_ of a table or view, of course, you use SQL, as in
select * from THE_TABLE_OR_VIEW;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 11:57 AM
Charles Hooper
 
Posts: n/a
Default Re: How to change field size using SQL against an oracle Database

BookerT wrote:
> I open up Oracle SQL*Plus and i want to change the field size for one
> of my columns in one of my databases. I have a generic SQL book, but
> when I try some of the commands, they don't seem to work in SQL*PLUS
>
> How can I perform this procedure on a table called INQUIRIES within my
> database. I want to change the field size from 10 , to say , 60


Generic SQL books will offer you a good start, but you will soon
recognize that SQL statements and commands are not fully portable from
one database platform to another.

The command to alter a table's column width (field size, number of
characters that can be stored) looks like this:
ALTER TABLE
MY_TABLE
MODIFY (
MY_COLUMN VARCHAR2(60));

In the above, replace MY_TABLE with the appropriate table name, and
MY_COLUMN with the appropriate column (field) name.

> I even wanted to jus ttry the EXPLAIN command to view the table, but
> when I type EXPLAIN INQUIRIES, i get a missing keyword error.


DESC MY_TABLE

The above command lists the columns in the table MY_TABLE and the
maximum column sizes and numeric precision.

SELECT
*
FROM
USER_TABLES
WHERE
TABLE_NAME='MY_TABLE';

The above lists information specific to the table: owner, number of
rows, approximate row length, etc.

SELECT
*
FROM
USER_TAB_COLUMNS
WHERE
TABLE_NAME='MY_TABLE';

The above lists all columns in the table, column order, and the maximum
column sizes and numeric precision. Additionally, if statistics are
collected, the minimum and maximum values for the column, density, and
various other parameters.

Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2008, 11:57 AM
BookerT
 
Posts: n/a
Default Re: How to change field size using SQL against an oracle Database

Thanks,

Yes i ended up finding an old oracle 8 book in the office, and it said
to do exactly what you typed. So yes, I quickly found out, my generic
SQL book, just led me to the right neighborhood, but not on the same
block

Thanks again Charles



Charles Hooper wrote:
> BookerT wrote:
> > I open up Oracle SQL*Plus and i want to change the field size for one
> > of my columns in one of my databases. I have a generic SQL book, but
> > when I try some of the commands, they don't seem to work in SQL*PLUS
> >
> > How can I perform this procedure on a table called INQUIRIES within my
> > database. I want to change the field size from 10 , to say , 60

>
> Generic SQL books will offer you a good start, but you will soon
> recognize that SQL statements and commands are not fully portable from
> one database platform to another.
>
> The command to alter a table's column width (field size, number of
> characters that can be stored) looks like this:
> ALTER TABLE
> MY_TABLE
> MODIFY (
> MY_COLUMN VARCHAR2(60));
>
> In the above, replace MY_TABLE with the appropriate table name, and
> MY_COLUMN with the appropriate column (field) name.
>
> > I even wanted to jus ttry the EXPLAIN command to view the table, but
> > when I type EXPLAIN INQUIRIES, i get a missing keyword error.

>
> DESC MY_TABLE
>
> The above command lists the columns in the table MY_TABLE and the
> maximum column sizes and numeric precision.
>
> SELECT
> *
> FROM
> USER_TABLES
> WHERE
> TABLE_NAME='MY_TABLE';
>
> The above lists information specific to the table: owner, number of
> rows, approximate row length, etc.
>
> SELECT
> *
> FROM
> USER_TAB_COLUMNS
> WHERE
> TABLE_NAME='MY_TABLE';
>
> The above lists all columns in the table, column order, and the maximum
> column sizes and numeric precision. Additionally, if statistics are
> collected, the minimum and maximum values for the column, density, and
> various other parameters.
>
> Charles Hooper
> PC Support Specialist
> K&M Machine-Fabricating, Inc.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:42 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com