开发者

Syntax for INSERTing into a table with no values?

开发者 https://www.devze.com 2022-12-18 18:56 出处:网络
I have a table created with the following schema: CREATE TABLE [dbo].[Visualizations] ( VisualizationIDint identity (1,1)NOT NULL

I have a table created with the following schema:

CREATE TABLE [dbo].[Visualizations]
(
    VisualizationID     int identity (1,1)      NOT NULL
)

Since the table has no settable fields, I'm not sure how to insert a record. I tried:

INSERT INTO [Visualizations];
INSERT INTO [Visualizations] () VALUES ();

Neither work. What is the proper syntax to do this?

Edit: Since a number of people seem confused by my table, it is used purely to repre开发者_JAVA技巧sent a parent of a number of sub-tables... each one references this table by FK and each of those FKs are PKs, so that across all of those tables, the IDs are unique.


See this (example "F. Load data using the DEFAULT VALUES option"):

INSERT INTO [Visualizations] DEFAULT VALUES;


Trigger the identity insert with null

insert into
            Visualizations
values
           (null);


Maybe you need to add a dummy column to do this, and just insert NULL into it, the dummy column would allow for NULLs. Although your table structure does not make sense, I would suggest this in order for it to work.

0

精彩评论

暂无评论...
验证码 换一张
取 消