• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Memory allocation

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to oracle and would like to know how the data is stored in memory? For example i have declared a column of type varchar2(100) and i have entered a value into that column? How will the value will be stored in memory and what happens if i exceed the value.Does it autoextend or will it throw an error?

Thanx in advance,
Visu
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Does it autoextend or will it throw an error


It will throw and error. The main purpose of a database is to maintain data integrity, and data types are part of the rules and constraints the database will use to do this. VARCHAR is a short hand for "variable character", stating that you intend to store only character data of a variable length no longer than the stated maximum in this field. You define the maximum amount of character data you can store with the maximum_size parameter (in your example 200). The maximum_size parameter denotes the maximum amount of data you cna store in characters or bytes. You can explicitly state which you want to use, e.g. :

If you don't specify which you are using, Oracle uses the value of the NLS_LENGTH_SEMANTICS parameter (which is CHAR by default I think).

Something to be aware of: the upper limit of a VARCHAR2 data type is fixed at a certain number of bytes. So changing the database character set can change the maximum number of characters you can store in a VARCHAR2 field, since characters set can use a one, two or many bytes to store a single character.

If you want a more flexible maximum limit - for example if you are persisting user input which could be one line or 50 pages - you can use a CLOB. In this case the limit is 4GB I think.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And by the way, it is not how it is stored in memory that is the issue here, database rule define how the data is stored on disk.
 
visu Nekk
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Paul,I need one more clarification.

I have created an employee table.I am storing the values that are being repeated in a column in separate tables and linking them using a foreign key relationship.Is this a good practice?
Because I have multiple columns in which data is being repeated.Please suggest me.
Thanx in advance.
Regards,
Visu
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I understand what you mean by "data that is repeated". Could you post your DDL for the table?
 
visu Nekk
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Paul,

By repetition,I mean, a group of employees will have a manager and so on.so what i am thinking is to store the manager names in one table and link it to the employee table with a manager_id which acts a foreign key in the employee table and as a primary key in the managers table.
Thanx in advance,
Regards,
Visu
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, this sounds like a good idea. Unless, of course, managers are also employees (which sound plausible), then you'll need a more elegant solution.
 
visu Nekk
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Paul, But managers are also employees.Can u suggest me any solution.
Thanks in advance,
Regards,
Visu
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably want the employee table to have a foreign key constraint with itself then; between manager_id and employee_id. If it is possible for one employee to have more than one manager you'll need another lookup table to handle this multiplicity.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic