If you want to add a column to a table that has already been built, you can use the following code:Alter TableTable nameAdd columnColumn Namevarchar( -) not NULLThis statement adds a column to an existing table in the last column of the table. If we want to add a column in the specified, you can use:Alter TableTable nameAdd columnColumn Namevarchar( -) not NULLafter User1; note that the above command means adding addr columns to the User1 column. If you want to add to the first column, you can use:Alter TableTable nameAdd columnColumn Namevarchar( -) not NULLFirst ; Change the column name def to unit in table Yusheng Alter Tableweb1.new_table Change def unitCharDelete columns in table Yusheng, column name DefAlter TableYushengDrop columndef;
Copying table TablesCreate Tablenew table name (SelectId,name, Number, Numberid fromthe name of the table to copy); View the table's various data types describe ' student ' view the table's saved dataSelect * fromTable Name (SelectId,name, Number, Numberid fromtable name) Add DataInsert intoTable name (Id,name, Number, Numberid)Values(1,'Logic', -,1),(2,'HTML', the,1),(3,'Java OOP', the,1); Delete DataDelete fromTable namewherecondition; Modify the dataUpdateTable nameSetNumberid=2 whereConditional Descending orderSelectId,name, Number, Numberid fromTable nameOrder byIddesc; add an aliasSelectID (column name)'aliases', (column name) as 'aliases' fromTable name;
MySQL adds a column to a table, deletes a column, modifies the column name