Oracle,sqlserver,mysql Database Statement Tables

Source: Internet
Author: User

--Creating a table statement
ORACLE:
CREATE TABLE _table_name (
Column1 varchar2 () primary key,
Column2 number (5) not nul L,
Memo varchar2
),
Comment on column _table_name.column1
is ' This is column1 comment ';
SQL Server:
CREATE TABLE _table_name (
Column1 varchar () primary key,
Column2 int not NULL,
Memo varchar ( )
);
MYSQL:
Create table ' _table_name '
(
' Column1 ' VARCHAR () primary key COMMENT ' annotations ',
' Column2 ' varcha R () NOT null COMMENT ' annotations ',
PRIMARY key (' Column1 ')--the primary key definition can also be placed here
Engine=innodb DEFAULT CHARSET=GBK;

--Modify a field statement
ORACLE:
ALTER TABLE _table_name add/modify column_name varchar2 (505);
ALTER TABLE _table_name DR OP column column_name;
SQL Server:
ALTER TABLE _table_name add column_name VARCHAR;
ALTER TABLE _table_name ALTER COLUMN Column_ Name varchar (2000);
ALTER TABLE _table_name drop column column_name;
MYSQL:
ALTER TABLE _table_name add/modify column column_name varchar (watts);
ALTER TABLE _table_name drop ' Co Lumn_name ';

--Create DELETE index statement, index can only delete rebuild, cannot modify
ORACLE:
--PRIMARY key index
ALTER TABLE _TABLE_NAME add constraint index_name primary key (c olumn_name) using index tablespace URMSPK;
--Normal column index
CREATE index Index_name$cl2 on _table_name (column1_name,column2_name DESC) tablespace urmsidx;
--delete In addition to the Index
Drop index index_name;
SQL Server:
--primary key index
Alter table _table_name Add primary key (COLUMN_NAME);
ALTER TABLE _table_name add Constrai NT Index_name primary key CLUSTERED (column_name)
with (
Pad_index = off,
Ignore_dup_key = off,
STATISTICS _norecompute = off,
Allow_row_locks = on,
Allow_page_locks = on)
on URMSPK
Go

--Normal column index, non-unique index needs to be removed Unique nonclustered keyword
CREATE unique nonclustered INDEX [index_name] on [_table_name]
([Orgrange], [Showorder] D ESC)
with (
Pad_index = off,
Ignore_dup_key = off,
Drop_existing = off,
Statistics_norecompute = off,< br> sort_in_tempdb = off,
ONLINE = off,
Allow_row_locks = ON,
Allow_page_locks = ON)
on [urmsidx]
Go
--delete index
Drop index _table_name.idxname;
MYSQL:
--normal index
ALTER TABLE _table_name ADD index index_name (APPID, CreateDate DESC);
-Unique index
ALTER TABLE _table_name ADD UNIQUE index_name (column_list);
--PRIMARY key index
ALTER TABLE _table_name ADD PRIMARY key index_name (column_list);
 

--Delete Index
ALTER TABLE _table_name DROP INDEX index_name;

--INSERT statement
ORACLE:
Insert into _table_name (column_list) VALUES (' value_list ');
Sql server:
Insert into _table_name (column_list) VALUES (' value_list ');
Mysql:
Insert into Umframeset (' column_list ') VALUES (' Value_list '), (' Value_list2 ');--You can insert more than one record

--Modifying the table name
ORACLE:
ALTER TABLE leave Rename to Leave01;
Sql server:
EXEC sp_rename leave,leave01;
Mysql:
ALTER TABLE ' leave ' RENAME to ' leave01 ';
--Delete a table statement
ORACLE:
DROP TABLE table_name;
Sql server:
DROP TABLE table_name;
Mysql:
DROP TABLE table_name
--Delete statements for all tables
Sql server:
EXEC sp_msforeachtable ' drop table? ';
--Modifying column names
Sql server:
EXEC sp_rename ' table name. Column name ', ' new column name ', ' column ';
--Deleting records
ORACLE:
Delete (from) tablename where _column_name=?;

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.