DEV Community

Vahid Yousefzadeh
Vahid Yousefzadeh

Posted on

Oracle AI Database 26ai — Wide Tables

Before Oracle AI Database 26ai, the maximum number of columns allowed in a table or view was limited to 1000. If this limit was exceeded, Oracle would raise the following error:

ORA-01792: maximum number of columns in a table or view is 1000
Enter fullscreen mode Exit fullscreen mode

Starting with Oracle AI Database 26ai, this limitation has been significantly expanded, allowing each table to contain up to 4096 columns.

To take advantage of this new capability, the initialization parameter max_columns must be set to extended:

SQL> alter system set max_columns=extended scope=spfile;
System altered

Enter fullscreen mode Exit fullscreen mode
SQL>startup force
Enter fullscreen mode Exit fullscreen mode

After restarting the database, you can create or modify tables with more than 1000 columns. The following example demonstrates how to add columns up to this new limit:

SQL> declare
  2  comm varchar2(100);
  3  begin
  4    for i in 2..4095 loop
  5     comm:='alter table  tb add c'||''||i||' number';
  6     execute immediate comm;
  7    end loop;
  8  end;
  9  /
  PL/SQL procedure successfully completed
Enter fullscreen mode Exit fullscreen mode

Finally, verify the number of columns in the table:

SQL> select count(*) from dba_tab_columns p where p.table_name='TB';
  COUNT(*)
----------
      4095
Enter fullscreen mode Exit fullscreen mode

This result confirms that Oracle AI Database 26ai successfully supports wide tables with significantly more columns than previous versions.

Top comments (0)