1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SwiftData のテーブル構造を SQLite コマンドでみる

Last updated at Posted at 2024-09-06

SwiftData で Todo というモデルを一つ作って、

シミュレーター にて眺めます。

実際にどう構成されているか雰囲気が掴めるでしょう。

シミュレーターの対象ファイルの位置。

/Users/{USER_NAME}/Library/Developer/
  CoreSimulator/
  Devices/{DEVICE_ID}/
  data/Containers/Data/Application/{APP_ID}/Library/
  Application Support/

「Application Support」 ディレクトリ以下に該当ファイルがある。

default.store
default.store-shm
default.store-wal

いざ。

$ sqlite default.store

SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.

sqlite> .tables
ACHANGE             ATRANSACTIONSTRING  ZTODO               Z_MODELCACHE
ATRANSACTION        Z_METADATA          Z_PRIMARYKEY

sqlite> .schema ZTODO
CREATE TABLE ZTODO ( Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, Z_OPT INTEGER, ZTIME TIMESTAMP, ZTEXT VARCHAR );

sqlite> .headers on
sqlite> .mode column

sqlite> select * from ZTODO;
Z_PK  Z_ENT  Z_OPT  ZTIME             ZTEXT
----  -----  -----  ----------------  -----------------------------------------------------------
11    2      1      727759392.308872  2. Do, or do not. There is no try.
12    2      1      727759392.914907  3. Most things look better when you put them in a circle.
13    2      1      727759393.191901  4. Could not get advice.
14    2      1      727760485.069984  0. You're not that important; it's what you do that counts.
15    2      1      727760485.781123  1. Most things done in secrecy are better left undone.
16    2      1      727760486.503812  2. When in doubt, just take the next small step.
17    2      1      727760487.112024  3. Have a firm handshake.

しっかりとした雰囲気で、内部的なテーブル群も自動で作成され構成されています。

メモリー、キャッシュ、ストレージ、データベース というデータ記憶位置の確認するためにも必要では?

🤔 参考

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?