创建Mnesia数据库
 mnesia:create_schema([node()]).
 
在shell里输入该行代码即可创建一个mnesia数据库于当前文件夹下
编译器文件路径下同样也有
 
数据库表定义创建
之后是数据库表定义,打开数据库创建完成后,启动数据库,添加一些表定义,添加完毕后关闭数据库
-record(shop, {item, quantity, cost}).
-record(cost, {name, price}).
%% API
-export([do_this_once/0]).
do_this_once() ->
  mnesia:create_schema([node()]),
  mnesia:start(),
  mnesia:create_table(shop, [{attributes, record_info(fields, shop)}]),
  mnesia:create_table(cost, [{attributes, record_info(fields, cost)}]),
  mnesia:create_table(design, [{attributes, record_info(fields, design)}]),
  mnesia:stop().
 
按照书上的写编译会报错,少了一个record
 在record中加一行回去
-record(shop, {item, quantity, cost}).
-record(cost, {name, price}).
-record(design, {info, plan}).
 
这样就没问题了
 



















