Search code examples
erlangmnesia

erlang mnesia create table error


I am trying to create mnesia table from Erlang shell. I got error and the same error for the below syntax copied from mnesia help documents.

mnesia:create_table(employee,
    [{attributes, record_info(fields, employee)}]).

got the error

record employee undefined

tried various combinations, getting same error. mnesia already started.


Solution

  • You can try rd(employee, {emp_no, name, salary, sex, phone, room_no}). in the erlang shell.

    rd(RecordName, RecordDefinition) Defines a record in the shell. RecordName is an atom and RecordDefinition lists the field names and the default values. Usually record definitions are made known to the shell by use of the rr commands described below, but sometimes it is handy to define records on the fly.

    Please see this link:http://www.erlang.org/doc/man/shell.html