有谁知道如何解决这个ID问题?
例如 :
ID | Message
1 | Hi
2 | Philemon
3 | Car <-- Delete this row
4 | Tay
5 | Bye
Run Code Online (Sandbox Code Playgroud)
删除第3行时,行后的ID将自动更新并填写ID.
ID | Message
1 | Hi
2 | Philemon
3 | Tay
4 | Bye
Run Code Online (Sandbox Code Playgroud)
更多信息 :
private void btnDel_Click(object sender, EventArgs e)
{
using (testEntities Setupctx = new testEntities())
{
int ID = Int32.Parse(lblID.Text);
var DeleteSh = (from delsh in Setupctx.shifthours
where delsh.idShiftHours == ID
select delsh).Single();
Setupctx.DeleteObject(DeleteSh);
Setupctx.SaveChanges();
txtStart.Text = "";
txtStop.Text …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的数据迁移脚本.
Data_migration.sql
它的内容是
insert into table1 select * from old_schema.table1;
commit;
insert into table2 select * from old_schema.table2;
commit;
Run Code Online (Sandbox Code Playgroud)
并且在执行脚本时table1有pk_productname约束
SQL> @ "data_migration.sql"
Run Code Online (Sandbox Code Playgroud)
我将获得一个唯一的约束(pk_productname)违规.但是当我执行单独的sql语句时,我不会得到任何错误.这背后有任何原因.以及如何解决这个问题.
postgres 中的主键字段默认为 NOT NULL,还是在创建表时需要这样指定?