Adding only one value to the table in sql

前端 未结 6 1086
别跟我提以往
别跟我提以往 2020-12-31 05:26

I have a table named student which consists of (rollno, name, sem, branch)

If I want to INSERT only one value (i.e only name h

相关标签:
6条回答
  • 2020-12-31 05:48
    insert into student (name)
    select 'some name'
    

    or

    insert into student (name)
    values ('some name')
    
    0 讨论(0)
  • 2020-12-31 05:51
    insert into student(name) values("The name you wan to insert");
    

    Be careful not to forget to insert the primary key.

    0 讨论(0)
  • 2020-12-31 05:55

    To insert values into specific columns, you first have to specify which columns you want to populate. The query would look like this:

    INSERT INTO your_table_name (your_column_name)
    VALUES (the_value);
    

    To insert values into more than one column, separate the column names with a comma and insert the values in the same order you added the column names:

    INSERT INTO your_table_name (your_column_name_01, your_column_name_02)
    VALUES (the_value_01, the_value_02);
    

    If you are unsure, have a look at W3Schools.com. They usually have explanations with examples.

    0 讨论(0)
  • 2020-12-31 05:57

    First, if the table is all empty, just wanna make the column 'name' with values, it is easy to use INSERT INTO. https://www.w3schools.com/sql/sql_insert.asp.

    `INSERT INTO TABLE_NAME (COLUMN_NAME) VALUES ("the values")` 
    

    Second, if the table is already with some values inside, and only wanna insert some values for one column, use UPDATE. https://www.w3schools.com/sql/sql_update.asp

      UPDATE table_name SET column1 = value1 WHERE condition;
    
    0 讨论(0)
  • 2020-12-31 06:04

    Execute this query, if you want the rest of columns as "#", do insert # inside the single quote which is left blank in query.

    Also, there is no need of defining column name in the query.

    insert into student values('','your name','','');
    

    Thanks...

    0 讨论(0)
  • 2020-12-31 06:08

    Following works if other columns accept null or do have default value:

    INSERT INTO Student (name) VALUES('Jack');
    

    Further details can be found from the Reference Manual:: 13.2.5 INSERT Syntax.

    0 讨论(0)
提交回复
热议问题