查询表中的约束信息: SHOW KEYS FROM 表名; 示例: 创建depts表包含department_id该列为主键自动增长,department_name列不允许重复,location_id列不允许有空值。 create table depts(department_id int primary key auto_increment,department_name varcha
有一张表table1数据量大概130万,查询sql如下: select count(*) from( select distinct a.example_id,a.plan_id,a.trustor_id from table1 a where DEL_STATUS=0 and (example_id,1,2) in(...) and plan_id in(...) ) 查询花了将近40
修改表时添加和删除约束 ①非空约束 alter table students modify column s_name varchar(20) not null; #添加alter table students modify column s_name varchar(20) ; #删除 ②添加默认约束 alter table students modify column age int
创建表时添加约束 ①列级约束 演示: CREATE TABLE students(id INT PRIMARY KEY,#主建约束(唯一性,非空)s_name VARCHAR(10) NOT NULL, #非空s_sex CHAR(1) CHECK(s_sex='男' OR s_sex='女'),#检查约束(Mysql无效)s_seat INT UNIQUE,#唯一约束age IN
1、先从user_objects中查询到该表的object_id: select object_id from user_objects where object_name=upper('XXX--表名'); 2、根据查到的object_id知道使用该表的session: select * from v$lock where id1=&object_id; 3、在从v$session视图中