--删除主键 alter table 表名 drop constraint 主键名 --添加主键 alter table 表名 add constraint 主键名 primary key(字段名1,字段名2……) --添加非聚集索引的主键 alter table 表名 add constraint 主键名 primary key NONCLUSTERED(字段名1,字段名2……) 新建表: create table [表名] ( ,) PRIMARY KEY , ) default \'默认值…
--删除主键 alter table 表名 drop constraint 主键名--添加主键alter table 表名 add constraint 主键名 primary key(字段名1,字段名2……)--添加非聚集索引的主键alter table 表名 add constraint 主键名 primary key NONCLUSTERED(字段名1,字段名2……) 新建表: create table [表名] ( [自动编号字段] int IDENTITY (1,1) PRIMARY…
--删除主键alter table 表名 drop constraint 主键名--添加主键alter table 表名 add constraint 主键名 primary key(字段名1,字段名2……)--添加非聚集索引的主键alter table 表名 add constraint 主键名 primary key NONCLUSTERED(字段名1,字段名2……) 新建表: create table [表名] ( [自动编号字段] int IDENTITY (1,1) PRIMARY K…
唠叨几句:几年前的知识忘却了,整理一下笔记,提供一下方便 1.创建数据库表 设置主键 create table users( userid number(10) primary key, /*主键,自动增加*/ username varchar2(20) ); 附  删除表:drop table users; 2.创建序列自增 CREATE SEQUENCE user_Sequence INCREMENT BY 1 -- 每次加几个 START WITH 1 -- 从1开始计数 NOMAXVAL…
CREATE TABLE text(id INT(20) COMMENT '主键',NAME VARCHAR(20) COMMENT '姓名',PASSWORD VARCHAR(20) COMMENT '密码',PRIMARY KEY(id) KEY indexname (NAME))ENGINE = INNODB AUTO_INCREMENT 1 DEFAULT CHARSET = utf8 COMMENT '字符串' //注释 PRIMARY KEY(id)//主键 auto_increme…
一.创建表 create table testTable ( Id numbere, name varchar2(100), age number, createTime date, primary key(Id) ) 二.创建序列 create sequence seq_test 三.创建触发器 create or replace trigger autoId before insert on testTable for each Row when (NEW.ID is null) begin…
新建表 create table [表名]([自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,[字段1] nVarChar(50) default \'默认值\' null ,[字段2] ntext null ,[字段3] datetime,[字段4] money null ,[字段5] int default 0,[字段6] Decimal (12,4) default 0,[字段7] image null ,) 删除表 Drop table [表名] 插入数据…
Oracle数据库常用sql语句 ORACLE 常用的SQL语法和数据对象一.数据控制语句 (DML) 部分 1.INSERT (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, 字段名2, ……) VALUES ( 值1, 值2, ……);INSERT INTO 表名(字段名1, 字段名2, ……) SELECT (字段名1, 字段名2, ……) FROM 另外的表名; 字符串类型的字段值必须用单引号括起来, 例如: ’GOOD DAY’如果字段值里包含单引号’ 需要进行字…
一,数据控制语句 (DML) 部分 1.INSERT  (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, 字段名2, ……) VALUES ( 值1, 值2, ……); INSERT INTO 表名(字段名1, 字段名2, ……)  SELECT (字段名1, 字段名2, ……) FROM 另外的表名; 字符串类型的字段值必须用单引号括起来, 例如: ’GOOD DAY’ 如果字段值里包含单引号’ 需要进行字符串转换, 我们把它替换成两个单引号''. 字符串类型的字段值超过…
--SQL 语句为表添加字段并设置默认值 alter table Student --表名 add fee --添加的字段名 int --字段类型 not null --是否为空 --默认值 --修改字段的数据类型和是否为空 alter table Student alter column S_Sex ) null -- with 把查询出来的表当做源表,但是必须把数据库的兼容性设置为:90+ with t as (select * from Student) select * from t -…