我的PostgreSQL 9.6数据库中有一个表,有300万行.该表已经有一个空位图(它有另外两个DEFAULT NULL字段).我想在这个表中添加一个新的布尔可空列.我坚持这两个陈述之间的区别:
ALTER TABLE my_table ADD COLUMN my_column BOOLEAN;
ALTER TABLE my_table ADD COLUMN my_column BOOLEAN DEFAULT NULL;
Run Code Online (Sandbox Code Playgroud)
我认为这些陈述没有区别,但是:
DEFAULT新列提供值会使PostgreSQL重写所有元组,但我不认为这种情况是正确的,因为默认值是NULL.DEFAULT NULL)比第二个语句花了更多的时间.我不明白为什么.我的问题是:
ACCESS EXCLUSIVE这两个语句使用相同的锁类型()吗?NULL,以便在我使用的情况下为每个元组增加价值DEFAULT NULL吗?我想在Angular中使用组件的继承继承父模板.
介绍
我有一些基本组件(让我们称之为ParentComponent)和这个组件的几个孩子(Child1Component和Child2Component).我想在其中放置默认行为ParentComponent,然后在子组件中设置/扩展此行为.ParentComponent模板已包含所有需要的东西,所以我希望子组件默认使用此模板.
实现的第一个变体(不起作用Error: No template specified for component Child1Component):
@Component({
selector: 'app-parent',
templateUrl: './app-parent.component.html',
styleUrls: ['./app-parent.component.scss']
})
export class ParentComponent {
}
@Component({
selector: 'app-child1'
})
export class Child1Component extends ParentComponent {
}
@Component({
selector: 'app-child2'
})
export class Child2Component extends ParentComponent {
}
Run Code Online (Sandbox Code Playgroud)
我发现我可以设置templateUrl和styleUrls孩子父母的模板,但如果只会工作,ViewEncapsulation孩子被设置为None.
第二个变种(它有效,但我不喜欢它):
@Component({
selector: 'app-parent',
templateUrl: './app-parent.component.html',
styleUrls: ['./app-parent.component.scss']
})
export class ParentComponent …Run Code Online (Sandbox Code Playgroud) 我是Sails.js(v0.10.5)和Waterline ORM的新手.我在数据库中有3个表:users(id,name),roles(id,alias)和join table users_roles(user_id,role_id).重要的是不要更改数据库中的表名和字段名.我希望Policy实体成为User和Role之间的连接实体.这是一些映射代码:
//User.js
module.exports = {
tableName: 'users',
autoCreatedAt: false,
autoUpdatedAt: false,
attributes: {
id: {
type: 'integer',
required: true
},
name: {
type: 'string'
},
roles: {
collection: 'role',
via: 'users',
through: 'policy'
},
}
}
//Role.js
module.exports = {
tableName: "roles",
autoCreatedAt: false,
autoUpdatedAt: false,
attributes: {
id: {
type: 'integer',
required: true
},
alias: {
type: 'string',
required: true
},
users: {
collection: 'user',
via: 'roles',
through: 'policy'
}
}
}
//Policy.js
module.exports = { …Run Code Online (Sandbox Code Playgroud) 我有Symfony项目,其中有2个实体 - Building和Building_type.它们与ManyToMany单向关联相关联.所以,当我尝试访问我的控制器时,我有这个错误:
The target-entity Farpost\StoreBundle\Entity\Building_type cannot be found in 'Farpost\StoreBundle\Entity\Building#building_types'.
Run Code Online (Sandbox Code Playgroud)
Farpost/StoreBundle /实体/ Building.php:
namespace Farpost\StoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
*
*/
class Building
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="alias", type="string", length=255)
*/
protected $alias;
/**
* @var string
*
* @ORM\Column(name="number", type="string", length=255)
*/
protected $number;
/**
* @ORM\ManyToMany(targetEntity="Building_type")
* @ORM\JoinTable(name="buildings_types",
* joinColumns={@ORM\JoinColumn(name="building_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="building_type_id", referencedColumnName="id")} …Run Code Online (Sandbox Code Playgroud) angular ×1
doctrine-orm ×1
many-to-many ×1
orm ×1
php ×1
postgresql ×1
sails.js ×1
symfony ×1
typescript ×1
waterline ×1