Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: TO_UPPER on entire table?
User Rob Williamson wrote:
> To make sure all enties in one column are Upper Case you can do the
> following
>
> create table test2(
> lname varchar2(10) not null,
> fname varchar2(10),
> constraint test2_lname_ck CHECK ( TO_UPPER(lname)),
> constraint test2_fname_ck CHECK ( TO_UPPER(fname))
> );
>
>
> Is there away to just have one table level constraint that makes all
> columns in the whole table all upper case without having to write
> constraints for each column?
>
If your table exists, and has a lot of columns, and you want to add constraint to each column, you can use catalog entries for table to generate constraints.
--/ Example /--
SELECT
'ALTER TABLE '||TABLE_NAME||' ADD CONSTRAINT
TEST2_'||COLUMN_NAME||'_CK CHECK ( TO_UPPER('||COLUMN_NAME||'));'
FROM ALL_TAB_COLUMNS A
WHERE A.table_name = 'ALL_TAB_COLUMNS';
-- NoelReceived on Fri Jul 08 2005 - 02:20:45 CDT