A-A+

A SQLite foreign key example

2014年02月27日 SQLite 暂无评论 阅读 545 次

First, we define two database tables that don't have any foreign keys:

Next, we define a SQLite table that has two foreign keys, one that relates our new orders table back to the customers table, and a second foreign key that relates the orders table back to the salespeople table:

As you can see, the SQLite foreign key syntax is very similar to other databases.

Sample SQLite foreign key data

If you'd like to test this SQLite foreign key example in your own SQLite database, here's some sample data for each of these tables:

I just tested these SQLite foreign key examples on my system, using SQLite version 3.4.0, and they all work fine.

标签:
蜗牛的梦想
Copyright © Linux系统运维联盟 保留所有权利.   Theme  Ality 京公网安备11011402000199号 京ICP备14047887号

用户登录