SQL语句PART11
1. My test: (create and grant the sysdba to a new user by SQL*Plus)
CREATE USER FJTEST1 IDENTIFIED BY JEANJEANFANG;
GRANT SYSDBA TO FJTEST;
REVOKE SYSDBA from FJTEST;
CONNECT FJTEST1/JEANJEANFANG AS SYSDBA;
2. Using ORAPWD in windows:
C:\» ORAPWD;
(show help information)
3. to see the password file:
Grammer: ORACLE_BASE\ORACLE_HOME\database» attrib
F:\oracle\ora92\database\attrib
** if want to create a user that can be connect as normal and can create table, you should grant “create session”, “resource” privileges to the user or it cannot connect as normal.
e.g.:
SQL»create user fj identified by fj;
SQL»grant create session to fj;
SQL»grant resource to fj;
Then the user “fj” can be connected as “normal” and the schema belonging to this user will be created, where he/she can create tables.
SQL» select * from user_sys_privs;
Use above statements to check user’s own system privileges.
2.How to create password file using ORAPWD
F:\oracle\ora92\database\ORAPWD FILE=F:\oracle=ora92\database\PWDmydb.ora PASSWORD=oracle ENTRIES=30
F:\oracle\ora92\database\sqlplus /nolog
SQL» connect SYS/oracle AS SYSDBA
ERROR: ORA-01031: insufficient privileges
(如果发生以上错误, 说明在ORACLE中开启了多于一个的数据库, 并且处于STARTUP状态.此时要连接必须用: connect SYS/oracle@SID AS SYSDBA, 必须在F:\oracle\ora92\network\admin\TNSNAMES.ORA里面定义过, 如果连接的是个别数据库,就不会报告这样的错误)
TNSNAMES.ORA 定义方式:
FJDB.SIIC.COM =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = fangjin)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = fjdb)
)
)
** or use the following command in dos state:
C: \ set oracle_sid = “jeandb”
C:\ sqlplus /nolog
SQL» connect sys/jeandb as sysdba;
3. How to create an oracle database in windows manually
Step1: setting environment var
相关文档:
第二十题:
怎么样抽取重复记录
表:
id name
--------
1 test1
2 test2
3 test3
4 test4
5 test5
6 test6
2 test2
3 test3
2 test2
6 test6
查出所有有重复记录的数据,用一句sql 来实现
create table D(
id varchar (20),
name varchar (20)
)
insert into D values('1','test1')
insert into D v ......
包由包规范和包体两部分组成。
1、包规范(Package Specification)
包规范,也叫做包头,包含了有关包的内容的信息。但是,它不包含任何过程的代码。
创建包头的语法一般如下
CREATE [OR REPLACE] PACKAGE package_name {IS | AS}
Procedure_name | function_name | variable_declaration | type_def ......
--1加内存表
EXEC sp_tableoption '表名','pintable', 'true'
--2卸载内存表
EXEC sp_tableoption '表名','pintable', 'false'
--2查询是否有内存表驻留
SELECT * from INFORMATION_SCHEMA.Tables
WHERE TABLE_TYPE = 'BASE TABLE'
AND OBJECTPROP ......
Oracle SQL(partI)
Data manipulation language(DML): select, insert, update, delete, merge.
Data definition language(DDL): create, alter, drop, rename, truncate, comment
Data control language(DCL): grant, revoke
Transaction control: commit, rollback, savepoint
Arithmetic Expressions:
+, -, *, / ......
constraint Example:
1. grammer:
create table [schema.]table
(column datatype [DEFAULT expr]
[column_constraint], ...
[table_constraint] [,......]);
2. example of a column_level constraint:
create table empl ......