sqlite重用不再使用的唯一/主键

时间:2019-04-01 07:29:56

标签: sql sqlite

我想知道是否:

  1. 如果已删除了包含要重用的值的旧表行,则可以在表上重用唯一项:这意味着在任何给定时间该值都是唯一的,但是在历史记录中,相同的值可能会已被使用....
  2. 与“创建唯一索引”相同-再次:在任何给定时间,值都是唯一的,但是在历史记录中,使用了相同的值
  3. 主键条件相同

1 个答案:

答案 0 :(得分:0)

唯一的索引/约束是对表内值的要求。这不适用于已删除的行。

如果您尝试在交易中进行更改,则可能会遇到问题。例如,以下代码会生成唯一约束错误:

$ curl -i https://api.stripe.com/v1/checkout/sessions \
>   -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
>   -H "Stripe-Version: 2019-03-14; checkout_sessions_beta=v1" \
>   -d success_url="https://example.com/success" \
>   -d cancel_url="https://example.com/cancel" \
>   -d payment_method_types[]=card \
>   -d line_items[][name]=T-shirt \
>   -d line_items[][description]="Comfortable cotton t-shirt" \
>   -d line_items[][amount]=1500 \
>   -d line_items[][currency]=usd \
>   -d line_items[][quantity]=2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   962  100   699  100   263    456    171  0:00:01  0:00:01 --:--:--   627HTTP/2 200
server: nginx
date: Mon, 01 Apr 2019 11:27:20 GMT
content-type: application/json
content-length: 699
access-control-allow-credentials: true
access-control-allow-methods: GET, POST, HEAD, OPTIONS, DELETE
access-control-allow-origin: *
access-control-expose-headers: Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required
access-control-max-age: 300
cache-control: no-cache, no-store
request-id: req_JC3iAqNt9tNrSb
stripe-version: 2019-03-14; checkout_sessions_beta=v1
strict-transport-security: max-age=31556926; includeSubDomains; preload

{
  "id": "cs_PlmiKmZH270fDtHvR3GMTU7QReUroEf0hQfcIpdih5uLtHQVNd4rv2CGQQgsX",
  "object": "checkout.session",
  "cancel_url": "https://example.com/cancel",
  "client_reference_id": null,
  "customer": null,
  "customer_email": null,
  "display_items": [
    {
      "amount": 1500,
      "currency": "usd",
      "custom": {
        "description": "Comfortable cotton t-shirt",
        "images": null,
        "name": "T-shirt"
      },
      "quantity": 2,
      "type": "custom"
    }
  ],
  "livemode": false,
  "locale": null,
  "payment_intent": "pi_1EKOIO2eZvKYlo2CDVPVKZjH",
  "payment_method_types": [
    "card"
  ],
  "subscription": null,
  "success_url": "https://example.com/success"
}