Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6726461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:55:49+00:00 2026-05-26T09:55:49+00:00

What is the way to find fields info(i.e field names) for ets table in

  • 0

What is the way to find fields info(i.e field names) for ets table in erlang ?

I have tried ets:info(TableName), ets:i(TableName). First one gives the detail about the table like memory,owner,size,named_table,keypos,protection etc. Second one gives the details about the entries present in the table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:55:50+00:00Added an answer on May 26, 2026 at 9:55 am

    The problem is that ETS works on tuples not records so there are no field names as such. Even if you do use records ETS only sees the tuples.

    Mnesia uses and knows about records.

    EDIT: A longer comment to @niting112’s comment.

    Records are, of course, just syntactic sugar for tuples providing, amongst other things, named fields. They are purely compile-time constructions and at an early stage in the compiler all record operations are transformed in corresponding tuple operations. Internally there are just tuples. The record name becomes the first element in the tuple and the fields are the other elements.

    Seeing ETS works on tuples we can use records for defining the tuples which are in a table. So if we have:

    -define(foo, {a,b=0,c}).
    

    then we can add objects to a table using:

    ets:insert(Table, #foo{a="Joe",c=1}),
    ets:insert(Table, #foo{a="Robert,c=2}),
    ets:insert(Table, #foo{a="Mike",c=3}),
    

    and we have added three tuples of 4 elements each. It is important to remember that if we are using records to define the table elements then we should make sure to set the key position to the index of the record field we wish to use as index. By default the key position is 1 which is just the record name which is generally not what we want.

    We can use “patterns” to retrieve objects from a table. Remember that there is no pattern datatype in Erlang and what we are really doing is constructing tuples which are interpreted as patterns. In these “patterns” the atoms '$1', '$2', '$3', … are interpreted as variables and the atom '_' is interpreted as the don’t care variable. So we could use the tuple {foo,'$1','_','$2'} as a pattern and the variables '$1' and '$2' will be “bound” the records fields a and c respectively. This is what is done with the functions ets:match, ets:match_object and ets:match_object and also in an extended form in ets:select.

    We can also use the record definitions to generate these “patterns” to retrieve elements from a table. We just use the record constructor syntax, so #foo{a='$1',b='_',c='$2'} generates the same tuple “pattern” as the example in the previous paragraph. There is some special syntax for records which is VERY useful for generating these “patterns”: the special (and normally illegal) field name _ is used to define a default value for all fields which aren’t explicitly given in the constructor. So in these cases we can use _='_' to set all unspecified fields to the “don’t care variable” '_'. Perfect for patterns in ets matching. So the “pattern” #foo{b=49,_='_'} becomes the tuple {foo,'_',49,'_'}.

    N.B. These are the not normal patterns used in normal pattern matching but data interpreted as pattern by ETS. Very different things.

    Sorry for going a bit overboard here, I got carried away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wondering if anyone has ever managed to find a way to have a
can't find an answer to this one... I have a form that detects changed
I find way too many projects to get involved in, way to many languages
Is there a way to find the name of the program that is running
Is there a way to find the number of files of a specific type
Is there any way to find out if a file is a directory? I
As a way to find inspiration and improve my PHP skills, I am looking
Is there a way to find the maximum and minimum defined values of an
Is there a way to find the number of lines of code used in
Is there any way to find out what exceptions might be thrown by any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.