In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to write the sentence of adding fields in sql, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
What is the statement for adding fields to sql?
The standard SQL statement for adding a field to a data table is written as follows:
Alter table table name add (field type) [default 'input default'] [null/not null]
For example:
ALTER TABLE employee ADD spbh varchar (20) NOT NULL Default 0
It means to add the field spbh to the table employee, which is of type varchar, size 20, and is not allowed to be empty, and the initial default value is 0.
Extended data:
Other commonly used SQL statements:
1. Modify a field property in the data table and add comments to it.
Statement format:
Comment on column library name. Table name. Field name is' comments entered'
Example: if I want to add a comment to the document_type field of the test table in the ers_data library, the sql statement is:
Comment on column ers_data.test.document_type is' File Type'
2. Modify a field type in the data table.
Statement format:
Alter table table name modiy (field type [default 'input default'] [null/not null], field type [default 'input default'] [null/not null])
Modify multiple fields separated by commas.
Example: if you want to change the type of office classroom of a field in the teacher teacher table to char (20), and the default value is "office", the corresponding sql is:
ALTER TABLE teacher ALTER COLUMN classroom VARCHAR (20) NOT NULL default "Office"
3. Delete a field in the data table.
Statement format:
Alter table table name drop (field)
Example: to delete the field age in table student, you can use the following sql:
Alter table student drop age; thank you for reading this article carefully. I hope the article "how to write sentences for adding fields in sql" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.