Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax for INSERTing into a table with no values?

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 represent 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.

like image 668
David Pfeffer Avatar asked Jan 27 '10 15:01

David Pfeffer


People also ask

How do you insert an empty value in a table?

You can insert NULL value into an int column with a condition i.e. the column must not have NOT NULL constraints. The syntax is as follows. INSERT INTO yourTableName(yourColumnName) values(NULL);

What is the syntax to insert data into the table?

If you want to add data to your SQL table, then you can use the INSERT statement. Here is the basic syntax for adding rows to your SQL table: INSERT INTO table_name (column1, column2, column3,etc) VALUES (value1, value2, value3, etc); The second line of code is where you will add the values for the rows.

What is the correct syntax for insert into?

There are two basic syntax of INSERT INTO statement is as follows: INSERT INTO TABLE_NAME (column1, column2, column3,... columnN)] VALUES (value1, value2, value3,... valueN);

How can you insert data into a table without using insert command in SQL?

Your best bet is to copy-paste the data from the Word document into a text file and then use perl, python, java, etc. to generate your insert statements.


1 Answers

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

INSERT INTO [Visualizations] DEFAULT VALUES; 
like image 145
Anton Gogolev Avatar answered Sep 19 '22 00:09

Anton Gogolev