怎么创建sqlite的主外键关联。。。要具体的代码。。或者帮我解决问题: 30
db.execSQL("createtable"+OnlineTable+"("+videoId+"integer,"+name+"text,"+type+"text,"...
db.execSQL("create table "+OnlineTable+
"("+videoId +" integer,"
+name+" text,"+type+" text,"+region+" text,"+year+
" text,"+actor+" text,"
+television+" text,"+introduction +" text,"+
collection+" text ,"
+number+" integer primary key not null,"
+" references "+JujiTable+"("+number+"))");
db.execSQL("create table "+JujiTable+
"("+videoId+" integer ,"
+webside+" text,"+link+" text,"+number+" integer primary key)");
/*
//创建添加的触发器
db.execSQL("create trigger fk_Movie_deptid " +
"before insert on "+OnlineTable+" for each row begin " +
"select case when ((select "+number+" from "+JujiTable+
" where "+number+"=new."+number+")is null) then raise " +
"(abort,'foreign key violation') end;end");*/
//创建触发器
db.execSQL("create trigger fk_Movie_deptid " +
"after insert on "+OnlineTable+" for each row begin " +
"select case when ((select "+number+" from "+JujiTable+
" where "+number+"=new."+number+")is null) then raise " +
"(ABORT,'Foreign Key Violation') end;end");
//创建视图
db.execSQL("create view "+ viewEmps+" as select "+OnlineTable+"."+videoId+" as _id,"
+
""+OnlineTable+"."+type+","+
OnlineTable+"."+actor+","
+OnlineTable+"."+name+","
+OnlineTable+"."+number+","
+OnlineTable+"."+television+","
+OnlineTable+"."+year+","
+OnlineTable+"."+introduction+","
+OnlineTable+"."+collection+","
+OnlineTable+"."+region+","+
""+JujiTable+"."+webside+","+JujiTable+"."+videoId+","
+JujiTable+"."+number+","
+JujiTable+"."+link+""
+" from "+OnlineTable+
" join "+JujiTable+" on "+OnlineTable+"."+number+"="+JujiTable+"."+number+""); 展开
"("+videoId +" integer,"
+name+" text,"+type+" text,"+region+" text,"+year+
" text,"+actor+" text,"
+television+" text,"+introduction +" text,"+
collection+" text ,"
+number+" integer primary key not null,"
+" references "+JujiTable+"("+number+"))");
db.execSQL("create table "+JujiTable+
"("+videoId+" integer ,"
+webside+" text,"+link+" text,"+number+" integer primary key)");
/*
//创建添加的触发器
db.execSQL("create trigger fk_Movie_deptid " +
"before insert on "+OnlineTable+" for each row begin " +
"select case when ((select "+number+" from "+JujiTable+
" where "+number+"=new."+number+")is null) then raise " +
"(abort,'foreign key violation') end;end");*/
//创建触发器
db.execSQL("create trigger fk_Movie_deptid " +
"after insert on "+OnlineTable+" for each row begin " +
"select case when ((select "+number+" from "+JujiTable+
" where "+number+"=new."+number+")is null) then raise " +
"(ABORT,'Foreign Key Violation') end;end");
//创建视图
db.execSQL("create view "+ viewEmps+" as select "+OnlineTable+"."+videoId+" as _id,"
+
""+OnlineTable+"."+type+","+
OnlineTable+"."+actor+","
+OnlineTable+"."+name+","
+OnlineTable+"."+number+","
+OnlineTable+"."+television+","
+OnlineTable+"."+year+","
+OnlineTable+"."+introduction+","
+OnlineTable+"."+collection+","
+OnlineTable+"."+region+","+
""+JujiTable+"."+webside+","+JujiTable+"."+videoId+","
+JujiTable+"."+number+","
+JujiTable+"."+link+""
+" from "+OnlineTable+
" join "+JujiTable+" on "+OnlineTable+"."+number+"="+JujiTable+"."+number+""); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询