In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
SQL how to determine whether the field column exists, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
The copy code for adding fields is as follows: alter table docdsp add dspcode char
The copy code for deleting fields is as follows: ALTER TABLE table_NAME DROP COLUMN column_NAME
The copy code for modifying the field type is as follows: ALTER TABLE table_name ALTER COLUMN column_name new_data_type
Rename sp_rename changes the name of a user-created object in the current database, such as a table, column, or user-defined data type. The syntax copy code is as follows: sp_rename [@ objname =] 'object_name', [@ newname =]' new_name' [, [@ objtype =] 'object_type']
-- suppose the table to be processed is named: tb
-- determine whether there is a primary key in the table to which the column is to be added. If exists (select 1 from sysobjects where parent_obj=object_id ('tb') and xtype='PK') beginprint' table already has a primary key. Columns can only be added as ordinary columns.'
-- add a column of type int. The default value is 0alter table tb add column name int default 0 endelsebeginprint'No primary key in the table, add primary key column'
-add a column of type int. The default value is 0alter table tb add column name int primary key default 0 end/*/
To determine whether there is a name field in table1, the copy code is as follows: if exists (select * from syscolumns where id=object_id ('table1') and name='name') beginselect * from people;end
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.