sql http://dbpatterns.com/documents/577e3a6f1514b4252236e36c/export/sqlite

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql http://dbpatterns.com/documents/577e3a6f1514b4252236e36c/export/sqlite相关的知识,希望对你有一定的参考价值。

@ECHO OFF

set db=db.sqlite

set script=script_fixed.sql

if exist %db% del %db%

sqlite3 %db% < %script%

pause
#!/usr/bin/env bash

db=db.sqlite

script=script_fixed.sql

rm $db


sqlite3 $db < $script

http://dbpatterns.com/documents/577e3a6f1514b4252236e36c/export/sqlite
3,4c3,6
< 	"oda_id" int FOREIGN KEY("oda_id") REFERENCES "Oda" ("id"),
< 	"status_id" int FOREIGN KEY("status_id") REFERENCES "Status" ("id")
---
> 	"oda_id" int, 
> 	"status_id" int,
> 	FOREIGN KEY("oda_id") REFERENCES "Oda" ("id"),
> 	FOREIGN KEY("status_id") REFERENCES "Status" ("id")
8c10,11
< 	"daire_id" int FOREIGN KEY("daire_id") REFERENCES "Daire" ("id")
---
> 	"daire_id" int, 
> 	FOREIGN KEY("daire_id") REFERENCES "Daire" ("id")
12c15,16
< 	"kat_id" int FOREIGN KEY("kat_id") REFERENCES "Kat" ("id")
---
> 	"kat_id" int, 
> 	FOREIGN KEY("kat_id") REFERENCES "Kat" ("id")
16c20,21
< 	"bina_id" int FOREIGN KEY("bina_id") REFERENCES "Bina" ("id")
---
> 	"bina_id" int, 
> 	FOREIGN KEY("bina_id") REFERENCES "Bina" ("id")
20c25,26
< 	"site_id" int FOREIGN KEY("site_id") REFERENCES "Site" ("id")
---
> 	"site_id" int, 
> 	FOREIGN KEY("site_id") REFERENCES "Site" ("id")
27c33,34
< 	"ada_id" int FOREIGN KEY("ada_id") REFERENCES "Ada" ("id")
---
> 	"ada_id" int, 
> 	FOREIGN KEY("ada_id") REFERENCES "Ada" ("id")
CREATE TABLE "Led" (
	"id" int PRIMARY KEY,
	"oda_id" int FOREIGN KEY("oda_id") REFERENCES "Oda" ("id"),
	"status_id" int FOREIGN KEY("status_id") REFERENCES "Status" ("id")
);
CREATE TABLE "Oda" (
	"id" int PRIMARY KEY,
	"daire_id" int FOREIGN KEY("daire_id") REFERENCES "Daire" ("id")
);
CREATE TABLE "Daire" (
	"id" int PRIMARY KEY,
	"kat_id" int FOREIGN KEY("kat_id") REFERENCES "Kat" ("id")
);
CREATE TABLE "Kat" (
	"id" int PRIMARY KEY,
	"bina_id" int FOREIGN KEY("bina_id") REFERENCES "Bina" ("id")
);
CREATE TABLE "Bina" (
	"id" int PRIMARY KEY,
	"site_id" int FOREIGN KEY("site_id") REFERENCES "Site" ("id")
);
CREATE TABLE "Ada" (
	"id" int PRIMARY KEY
);
CREATE TABLE "Site" (
	"id" int PRIMARY KEY,
	"ada_id" int FOREIGN KEY("ada_id") REFERENCES "Ada" ("id")
);
CREATE TABLE "Status" (
	"id" int PRIMARY KEY,
	"name" varchar(255)
);
CREATE TABLE "Led" (
	"id" int PRIMARY KEY,
	"oda_id" int, 
	"status_id" int,
	FOREIGN KEY("oda_id") REFERENCES "Oda" ("id"),
	FOREIGN KEY("status_id") REFERENCES "Status" ("id")
);
CREATE TABLE "Oda" (
	"id" int PRIMARY KEY,
	"daire_id" int, 
	FOREIGN KEY("daire_id") REFERENCES "Daire" ("id")
);
CREATE TABLE "Daire" (
	"id" int PRIMARY KEY,
	"kat_id" int, 
	FOREIGN KEY("kat_id") REFERENCES "Kat" ("id")
);
CREATE TABLE "Kat" (
	"id" int PRIMARY KEY,
	"bina_id" int, 
	FOREIGN KEY("bina_id") REFERENCES "Bina" ("id")
);
CREATE TABLE "Bina" (
	"id" int PRIMARY KEY,
	"site_id" int, 
	FOREIGN KEY("site_id") REFERENCES "Site" ("id")
);
CREATE TABLE "Ada" (
	"id" int PRIMARY KEY
);
CREATE TABLE "Site" (
	"id" int PRIMARY KEY,
	"ada_id" int, 
	FOREIGN KEY("ada_id") REFERENCES "Ada" ("id")
);
CREATE TABLE "Status" (
	"id" int PRIMARY KEY,
	"name" varchar(255)
);

以上是关于sql http://dbpatterns.com/documents/577e3a6f1514b4252236e36c/export/sqlite的主要内容,如果未能解决你的问题,请参考以下文章

sql 2008和sql 2012的区别

sql [sql技巧]一些sql技巧#sql

sql 2008 r2 在sql 2008上兼容么

SQL基础

有大神知道,sql server 中如何批量执行sql语句吗?

pl sql developer怎么执行sql