Mnesia判断数据库和表是否存在

1. 判断数据库是否存在

case mnesia:system_info(use_dir) of
    true ->
        alread_created;
    _ ->
        mnesia:create_schema([node()])
    end.

2. 判断表是否存在
case lists:member(agent_cache_table, mnesia:system_info(tables)) of
    true ->
        lager:info("The table agent_cache_table is exists in mnesia !!!");
    _ ->
        lager:info("The table agent_cache_table is not exists in mnesia !!!")
    end.

评论

暂无评论