In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you what are the nine common statements of sql in the database. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
I. Foundation
1. Description: create a database
CREATE DATABASE database-name
2. Description: delete the database
Drop database dbname
3. Description: backup sql server
-create a device for backing up data
USE master
EXEC sp_addumpdevice 'disk',' testBack','c:\ mssql7backup\ MyNwind_1.dat'
-start backup
BACKUP DATABASE pubs TO testBack
4. Description: create a new table
Create table tabname (col1 type1 [not null] [primary key], col2 type2 [not null],..)
Create a new table based on an existing table:
A:create table tab_new like tab_old (create a new table using the old table)
B:create table tab_new as select col1,col2... From tab_old definition only
5. Description: delete the new table
Drop table tabname
6. Description: add a column
Alter table tabname add column col type
Note: columns cannot be deleted after they are added. The data type cannot be changed after the column is added in DB2, and the only thing that can change is to increase the length of the varchar type.
7. Description: add primary key: Alter table tabname add primary key (col)
Description: delete primary key: Alter table tabname drop primary key (col)
8. Description: create an index: create [unique] index idxname on tabname (col … (.)
Delete index: drop index idxname
Note: the index is immutable and must be deleted and rebuilt if you want to change it.
9. Description: create view: create view viewname as select statement
Delete View: drop view viewname
Thank you for reading! This is the end of the article on "what are the nine commonly used sentences of sql in the database?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.