在SQL数据库中插入值

时间:2010-04-25 02:22:12

标签: sql insert

在SQL Server 2005中,我试图找出如何填写以下字段?任何形式的帮助将受到高度赞赏..

INSERT INTO [Fisharoo].[dbo].[Accounts]
       ([FirstName]
       ,[LastName]
       ,[Email]
       ,[EmailVerified]
       ,[Zip]
       ,[Username]
       ,[Password]
       ,[BirthDate]
       ,[CreateDate]
       ,[LastUpdateDate]
       ,[TermID]
       ,[AgreedToTermsDate])
 VALUES
       (<FirstName, varchar(30),>
       ,<LastName, varchar(30),>
       ,<Email, varchar(150),>
       ,<EmailVerified, bit,>
       ,<Zip, varchar(15),>
       ,<Username, varchar(30),>
       ,<Password, varchar(50),>
       ,<BirthDate, smalldatetime,>
       ,<CreateDate, smalldatetime,>
       ,<LastUpdateDate, smalldatetime,>
       ,<TermID, int,>
       ,<AgreedToTermsDate, smalldatetime,>)

3 个答案:

答案 0 :(得分:0)

如果您使用显式值,则只需键入它们即可。 您还可以使用Select INTO语法。

INSERT INTO [Fisharoo].[dbo].[Accounts]
       ([FirstName]
       ,[LastName]
       ,[Email]
       ,[EmailVerified]
       ,[Zip]
       ,[Username]
       ,[Password]
       ,[BirthDate]
       ,[CreateDate]
       ,[LastUpdateDate]
       ,[TermID]
       ,[AgreedToTermsDate])
 VALUES
       ('Bob'
       ,'Smith'
       ,'bob@bobsmith.com'
       ,0
       ,'11111'
       ,'bsmith'
       ,'mylittlepony'
       ,'1/1/1950'
       ,'4/24/2010 11:23 PM'
       ,'4/24/2010 11:23 PM'
       ,3
       ,null)

答案 1 :(得分:0)

INSERT INTO "Fisharoo" ("FirstName", "LastName", "Email", EmailVerified, "Zip", "Username", "Password", "BirthDate", "CreateDate", "LastUpdateDate", TermID, "AgreedToTermsDate")
VALUES ('Duck', 'Dummy', 'duckdummy@duck.de', 1, '12345', 'Ducky', 'test123', '2010-02-01', '2010-01-01', '2010-01-01', 3, '2010-01-01');

答案 2 :(得分:0)

我不确定你在这里问的是什么。这很简单吗?

INSERT INTO [Fisharoo].[dbo].[Accounts]
   ([FirstName]
   ,[LastName]
   ,[Email]
   ,[EmailVerified]
   ,[Zip]
   ,[Username]
   ,[Password]
   ,[BirthDate]
   ,[CreateDate]
   ,[LastUpdateDate]
   ,[TermID]
   ,[AgreedToTermsDate])
 VALUES
   ('Bob'
   ,'Dole'
   ,'bob.dole@gmail.com'
   ,1
   ,'75454'
   ,'bdole'
   ,'topsecret'
   ,'07-22-1923'
   ,'04-24-2010'
   ,'04-24-2010 21:31'
   ,123
   ,'04-24-2010')

这是一个真正的桌面设计还是仅仅是一个例子?因为如果它是真的,请不要将密码存储为varchar(50)。