Oracle 10g SQL Fundamentals II(学习笔记二第7-8章)

第七章分层检索
			语法:
				SELECT [LEVEL], column, expr...
				FROM   table
				[WHERE condition(s)]
				[START WITH condition(s)]
				[CONNECT BY PRIOR condition(s)] ;

            例如:
			SELECT employee_id, last_name, job_id, manager_id
			FROM   employees
			START  WITH  employee_id = 101
			CONNECT BY PRIOR manager_id = employee_id ;
			
			
			SELECT  last_name||' reports to '|| 
			PRIOR   last_name "Walk Top Down"
			FROM    employees
			START   WITH last_name = 'King'
			CONNECT BY PRIOR employee_id = manager_id ;

			
			第八章,正则表达式支持
			REGEXP_LIKE:
					语法:REGEXP_LIKE   (srcstr, pattern [,match_option])
			 例如:
                 SELECT first_name, last_name
					FROM employees
					WHERE REGEXP_LIKE (first_name, '^Ste(v|ph)en$');
			REGEXP_REPLACE
                    语法:
							REGEXP_REPLACE(srcstr, pattern [,replacestr [, position 
					   [, occurrence [, match_option]]]]) 
					   
			REGEXP_INSTR
					语法:
						REGEXP_INSTR  (srcstr, pattern [, position [, occurrence
							[, return_option [, match_option]]]]) 
								例如: 
									SELECT street_address, 
									   REGEXP_INSTR(street_address,'[^[:alpha:]]')
									FROM   locations 
									WHERE    
									   REGEXP_INSTR(street_address,'[^[:alpha:]]')> 1;
							
			REGEXP_SUBSTR
					语法:
					 REGEXP_SUBSTR (srcstr, pattern [, position 
               [, occurrence [, match_option]]])
			        例如:
 					SELECT REGEXP_SUBSTR(street_address , ' [^ ]+ ') "Road" FROM locations;

			   
			   
			 添加一个检查约束:
			 ALTER TABLE emp8 
				  ADD CONSTRAINT email_addr    
				  CHECK(REGEXP_LIKE(email,'@'))NOVALIDATE ;

 

你可能感兴趣的:(oracle)