我正在为网站创建数据库并希望在用户登录时存储用户的 IP 地址,我应该为 IP 使用什么数据类型?是否需要支持 IPv6?
这个脚本好不好,需要解析IP吗?
CREATE TABLE [dbo].[temp](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[userId] [bigint] NOT NULL,
[ip] [varchar](40) NOT NULL,
[dateTime] [datetime] NOT NULL,
CONSTRAINT [PK_temp] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]