GO --判断表是否存在方式1 if object_id(N'EF_User',N'U') is null --判断表是否存在方式2 --if not exists (select * from dbo.SysObjects WHERE id = object_id(N'[EF_User]') AND OBJECTPROPERTY(ID, 'IsTable') = 1) begin --直接创建自增且指定主键约束的表 CREATE TABLE [dbo].[EF_User]( ,) not nu
data sqlite> select * from author; id name age 1 jim 12 2 tom 11 sqlite> select * from book; id name author_id 1 learn java 1 2 learn python 1 3 learn c++ 2 models.py # -*- coding: UTF-8 -*- from __future__ import unicode_literals from django.db imp
Django的外键使用 from django.db import models # Create your models here. class Category(models.Model): name = models.CharField(max_length=) class Article(models.Model): title = models.CharField(max_length=) content = models.TextField() # 是由Category影响Artic
下面定义两个模型,一个主表,一个字表. 举例说明: 如何通过主表对象找到对应的子表对象? 如何通过子表对象找到对应的主表对象? class Person(models.Model); name = models.CharField('作者姓名', max_length=10) age = models.IntegerField('作者年龄') class Book(models.Model): person = models.ForeignKey(Person,related_name='per
select distinct pipeId=substring(a.PipeIn,b.number,charindex(',',a.PipeIn+',',b.number)-b.number) from B_PipeSet_Info a join master..spt_values b on b.type='P' where charindex(',',','+a.PipeIn,b.number)=b.number
models.py from django.db import models # Create your models here. class Category(models.Model): """ 文章分类 """ name = models.CharField(verbose_name='分类',max_length=32) class Article(models.Model): """ 文章表 "&
如下面的: create table applicant (id int not null auto_increment primary key, jobId int not null, studentId int not null, foreign key (studentId) references student(id), foreign key (jobId) references job(id) ); foreign key 后面要有(),有多个列则(index1,index2). (