換了公司,數據庫使用SQL server的
記錄一下,順便幫忙
1.設置自增列
#自增列不能直接修改,必須將原有ID列刪除,然後重新添加一列具有identity屬性的ID字段。
#比如你要修改的字段名爲id:
注:這隻適用於剛建完表的情況,如果此時主鍵已經使用過了,表中存在許多數據,不能使用該方法刪除主鍵,會導致數據丟失。(可行的方法,建一張相同的表來存儲數據,在修改,插入)。
alter table tb drop column id
alter table tb add id int identity(1,1)
2.設置主鍵
alter table tb alter column id int not null
alter table tb add constraint pkid primary key (id)
3.根據時間段選擇記錄
select * from tb where input_date between ‘2019-12-20 00:00:00’ and ‘2019-12-20 23:59:59’