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ÖпªÆôÁ˶àÓÚÒ»¸öµÄÊý¾Ý¿â,¡¡²¢ÇÒ´¦ÓÚ£Ó£Ô£Á£Ò£Ô£Õ£Ð״̬£®´ËʱҪÁ¬½Ó±ØÐëÓÃ:¡¡ connect SYS/oracle£ÀSID AS SYSDBA, ±ØÐëÔÚF:\oracle\ora92\network\admin£Ü£Ô£Î£Ó£Î£Á£Í£Å£Ó£®£Ï£Ò£ÁÀïÃ涨Òå¹ý£¬¡¡Èç¹ûÁ¬½ÓµÄÊǸö±ðÊý¾Ý¿â£¬¾Í²»»á±¨¸æÕâÑùµÄ´íÎó)
£Ô£Î£Ó£Î£Á£Í£Å£Ó£®£Ï£Ò£Á¡¡¶¨Ò巽ʽ£º
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. £Èow to create an oracle database in windows manually
Step1: setting environment var
Ïà¹ØÎĵµ£º
µÚʮһÌ⣺
Óбístudents(name,class,grade),ÇëÓñê×¼sqlÓï¾äÍê³É
name class grade
ÕÅÈý Êýѧ 81
ÀîËÄ ÓïÎÄ 70
ÍõÎå Êýѧ 90
ÕÅÈý ÓïÎÄ 60
ÀîËÄ Êýѧ 100
ÍõÎå ÓïÎÄ 90
ÍõÎå Ó¢Óï 81
ÒªÇó: ÓÃsqlÓï¾äÊä³ö¸÷ÃŹ¦¿Î¶¼´óÓÚ80·ÖµÄͬѧÐÕÃû?
create table students (
name varchar(25),
class varchar(25),
grad ......
1¡¢´¥·¢Æ÷µÄ¸ÅÄî
´¥·¢Æ÷Ò²ÊÇÒ»ÖÖ´øÃûµÄPL/SQL¿é¡£´¥·¢Æ÷ÀàËÆÓÚ¹ý³ÌºÍº¯Êý£¬ÒòΪËüÃǶ¼ÊÇÓµÓÐÉùÃ÷¡¢Ö´ÐкÍÒì³£´¦Àí¹ý³ÌµÄ´øÃûPL/SQL¿é¡£Óë°üÀàËÆ£¬´¥·¢Æ÷±ØÐë´æ´¢ÔÚÊý¾Ý¿âÖв¢ÇÒ²»Äܱ»¿é½øÐб¾µØ»¯ÉùÃ÷¡£
¶ÔÓÚ´¥·¢Æ÷¶øÑÔ£¬µ±´¥·¢Ê¼þ·¢ÉúµÄʱºò¾Í»áÏÔʽµØÖ´Ðиô¥·¢Æ÷£¬²¢ÇÒ´¥·¢Æ÷²»½ÓÊܲÎÊý¡£
´´½¨´¥·¢Æ÷µÄÓï·¨È ......
oracle ·½·¨ & ......
Subquery: (single-row subqueries and multi-rows subqueries).
select select_list
from table
where expr operator (select select_list from table);
single-row subqueries operator: =, >, >=, <, <=, <>
e.g.:
1. select department_id, min(salary) from employees group by department_id ......
CREATE VIEW MYVIEW
AS
SELECT * from bjxxdiweb_database2007.dbo.bm_tongji
UNION ALL
SELECT * from aa.DBO.chen
select * into aa..chen from bjxxdiweb_database2007.dbo.bm_tongji where 1=2
˵Ã÷£ºÊý¾Ý¿âAµÄ±íµÄ×Ö¶ÎÃû±ØÐëºÍÊý¾Ý¿âBµÄ±íµÄ×Ö¶ÎÃûÏàͬ£¬°üÀ¨Êý¾ÝÀàÐ͵ȡ£ ......