Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating tables dynamically at runtime

Is creating a table dynamically at runtime based on a user's interactions a good or bad thing for a web-app? (I'm talking java, but question probably applies to more).

like image 504
Mark W Avatar asked Aug 05 '11 14:08

Mark W


People also ask

Can tables be dynamically?

Dynamic tables in Excel are the tables where when a new value is inserted into it. As a result, the table adjusts its size by itself. To create a dynamic table in Excel, we have two different methods: making a table of the data from the table section while another using the offset function.

How to create table dynamically in Oracle?

EXECUTE IMMEDIATE 'CREATE TABLE '||P_TBL_NAME||' (Empname VARCHAR2(100), EmpId Number)';

What is a dynamic table?

. A dynamic tables is a table that changes its number of rows depending on the input received in your launch form. As business users fill out the launch form, their responses generate the appropriate number of rows in the table.


1 Answers

Tables are generally crucial to a user's interaction with the database. Consequently the absence of tables is fatal.

From this it follows, that creating tables on the fly, at runtime, is a bad practice because it means there is no guarantee of the user's experience. If a CREATE TABLE statement fails, for whatever reason, the user is stuffed.

So, it is q good idea to avoid business processes which rely on the runtime creation of tables. There are usually workarounds, except in very specific circumstances.

To a certain extent this depends on the flavour of RDBMS underpinning the application. For instance, Oracle has the concept of Global Temporary Tables which removes the call for dynamic table creation in almost all circumstances. But even without such fancy features, there are usually ways around it: for instance, adding A USERNAME column to a table and building a view on top of it which includes a WHERE clause filtering on USERNAME=USER.

Basically, DDL is expensive to execute, in terms of elapsed time and system resource. It creates transactional complexity. And it is risky: if it fails then the user cannot proceed. So for all these reasons it should be avoided.

like image 154
APC Avatar answered Sep 30 '22 12:09

APC