الانتقال إلى المحتوى

طريقة كتابة اوامر( Select ) للمبتدئين


abu_fahad

Recommended Posts

<span style='font-family:tahoma'></span>

</div><div align="center">بسم الله الرحمن الرحيم



Displaying Table Structure:

In SQL*Plus, you can display the structure of a table using the DESCRIBE command. The result of the command is to see the column names, Datatypes, and whether a column must contain data.
*********************
DESC[RIBE]  tablename
********************

Where:	tablename		is the name of any existing table, view, or synonym accessible to the user.

Example:

Display information about the structure of the S_DEPT table.

#####################
SQL> DESCRIBE  s_dept
#####################


NAME		NULL?		Type
---------		---------		-------
ID			NOT NULL		NUMBER (7)
NAME		NOT NULL		VARCHAR2 (25)
REGION_ID				NUMER (7)
###########################



Where:	Null?		Indicates that a column must contain data.

	Type		displays the datatype for a column.
&&&&&&&&&&&&&&&&&&&&&&&&
Datatype                       Description
=======================================
NUMBER (p,s)````          Description
***************************
VARCHAR2(s)                Number value having a maximum number of digits p , and the number of digits to the right of the decimal point s .
**********************************
DATE                    Variable length character value of maximum size s .
*************************************
CHAR(s)        Fixed length character value of size s.
================================



The Basic Query Block:

A SELECT statement retrieves information from the database, implementing all algebraic operators .

Syntax
¬+++++++++++++++++++++++
SELECT		(DISTINCT)	{* , column [alias] , …. }
FROM		table ;
+++++++++++++++++++++++

Where :	SELECT		is a list of at least one column .
	DISTINCT suppresses duplicates .
	*			select all columns .
	column		selects the named column .
	alias gives selected columns a different heading
	FROM table specifies the table containing the columns.

Selecting All Columns and Rows
The asterisk (*) selects all columns from the table .
Example 

List all columns and all rows from the S_DEPT table .
&&&&&&&&&&&&&&&&&&&&&&
SQL> SELECT   *
    2    FROM       s_dept;
##################################


ID	NAME				REGION_ID
----    ---------                                    ------------------
10	Finance				                 1
31	Sales						       1
32	Sales						       2
33	Sales						       3
34	Sales						       4
35	Sales						       5
41	Operations					       1
42	Operations					       2
43	Operations					       3
44	Operations					       4
45	Operations					       5
50	Administration				       1
12 Rows selected .
###################################################


Selecting Specific Columns: 

You restrict the query to display only certain columns by specifying the column names , separated by commas , in the SELECT clause .

Example: 

Display all department numbers, employee last names, and manager numbers in the S_EMP table .
######################
SQL> SELECT	dept_id, last_name, manager_id
    2	 FROM	s_emp;
**********************

DEPT_ID	LAST_NAME		MANAGER_ID
-------------	-------------------		---------------------
50	Velasquez
41	Ngao						 1
31	Nagayama					 1
10	Quick-to-see				 1
50	Ropeburn					 1
41	Urguhart					 2
42	Menchu					 2
43	Biri						 2
44	Catchpole					 2
…

25 rows selected   	 
==========================================



المعذرة بعض الأرقام بالعربي وبعض الفواصل مقلوبة مادري ليش
(( والدروس القادمة افضل ان شاء الله))
وشكر الأخوان الأفاضل القائمين على هذا النتدى
(( محبكم ابوفهد [email protected] )) :D

رابط هذا التعليق
شارك

  • بعد 1 سنة...

السلام عليكم
اولا مجهود تستحق عليه الشكر ولكن انت فى منتدي عربي فحاول ان توضح افكارك وشرحك مدعما باللغة العربي .
الامر الثاني اكتب ما تشاء من شرح ولكن على Text Document وارفقه فى المرفقات وستجد الاوامر مكتوبة بشكل سليم ان شاء الله وستجد من يرد عليك فى كتاباتك
وشكرا
ميجا

رابط هذا التعليق
شارك

  • بعد 3 سنة...

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   تمت استعادة المحتوى السابق الخاص بك.   مسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

جاري التحميل
×
×
  • أضف...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية