SQL Server and Oracle Modify table structure

Source: Internet
Author: User

SQL Server and Oracle Modify table structures are commonly used
SQL Server:
1. Add columns
ALTER TABLE users ADD address varchar (30);
2. Delete Columns
ALTER TABLE users DROP COLUMN address;
3. Modify the field type
Alter TABLE users ALTER COLUMN address varchar (80);
4. Rename the column:
EXEC sp_rename ' Wn_call_info. [Cust_code] ', ' cust_id ', ' COLUMN ';
5. Rename the table:
EXEC sp_rename ' customers ', ' custs ';

ORACLE:
1. Add columns
ALTER TABLE Sms_log ADD send_id number;
2. Delete Columns
ALTER TABLE users DROP COLUMN address;
3. Modify the field type
ALTER TABLE GROUP modify Creator_no varchar2 (50);

There is no replace table feature in SQL SERVER.
When creating a new table, you can tell if a table with that name already exists, and if it is, delete it after you create the

The following methods can be used to determine if a table exists: if OBJECT_ID (n ' usertablename ', n ' U ') is not NULL
DROP TABLE Usertablename

SQL Server and Oracle Modify table structure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.