fix: converted single to triple backticks14 (#36241)
This commit is contained in:
@ -8,38 +8,42 @@ localeTitle: ملموس
|
||||
|
||||
React Native ships مع عنصر `Button` يعمل مع العديد من تفاعلات `onPress` القياسية. بشكل افتراضي ، فإنه يعطي ملاحظات المستخدم عن طريق تغيير العتامة لإظهار الضغط على الزر. الاستعمال:
|
||||
|
||||
`<Button onPress={handlePress} title="Submit" />
|
||||
`
|
||||
```js
|
||||
<Button onPress={handlePress} title="Submit" />
|
||||
```
|
||||
|
||||
لحالات الاستخدام الأكثر تعقيدًا ، قام React Native بإنشاء واجهات برمجة التطبيقات للتعامل مع التفاعلات الصحفية المسماة `Touchables` .
|
||||
|
||||
`TouchableHighlight
|
||||
TouchableNativeFeedback
|
||||
TouchableOpacity
|
||||
TouchableWithoutFeedback
|
||||
`
|
||||
```
|
||||
TouchableHighlight
|
||||
TouchableNativeFeedback
|
||||
TouchableOpacity
|
||||
TouchableWithoutFeedback
|
||||
```
|
||||
|
||||
يمكن تصميم واستخدام كل من هذه المكونات القابلة للتشابك مع مكتبة ، مثل `Animated` المدمجة ، مما يتيح لك إنشاء أنواع خاصة بك من تعليقات المستخدمين المخصصة.
|
||||
|
||||
بعض الأمثلة على استخدام هذه المكونات:
|
||||
|
||||
`// with images
|
||||
<TouchableHighlight onPress={this.handlePress}>
|
||||
<Image
|
||||
style={styles.button}
|
||||
source={require('./logo.png')}
|
||||
/>
|
||||
</TouchableHighlight>
|
||||
|
||||
// with text
|
||||
<TouchableHighlight onPress={this.handlePress}>
|
||||
<Text>Hello</Text>
|
||||
</TouchableHighlight>
|
||||
`
|
||||
```js
|
||||
// with images
|
||||
<TouchableHighlight onPress={this.handlePress}>
|
||||
<Image
|
||||
style={styles.button}
|
||||
source={require('./logo.png')}
|
||||
/>
|
||||
</TouchableHighlight>
|
||||
|
||||
// with text
|
||||
<TouchableHighlight onPress={this.handlePress}>
|
||||
<Text>Hello</Text>
|
||||
</TouchableHighlight>
|
||||
```
|
||||
|
||||
يمكنك التعامل مع أنواع مختلفة من الضغط على الزر أيضًا. بشكل افتراضي ، يتم تكوين الأزرار و touchables للتعامل مع الصنابير العادية ، ولكن يمكنك أيضا أن تشير إلى وظيفة لاستدعاء اضغط مع الاستمرار على التفاعلات على سبيل المثال.
|
||||
|
||||
`<TouchableHighlight onPress={this.handlePress} onLongPress={this.handleLongPress}>
|
||||
`
|
||||
```js
|
||||
<TouchableHighlight onPress={this.handlePress} onLongPress={this.handleLongPress}>
|
||||
```
|
||||
|
||||
للاطلاع على جميع الأدوات المتوفرة المتوفرة وكيفية عمل هذه المكونات ، يمكنك الاطلاع على [شفرة مصدر جافا سكريبت لـ Touchables هنا](https://github.com/facebook/react-native/tree/master/Libraries/Components/Touchable) .
|
@ -20,8 +20,9 @@ Redux هو حاوية حالة يمكن التنبؤ بها لتطبيقات Jav
|
||||
|
||||
#### أين يتم تخزين هذه الحالة؟ Redux يوفر لك وظيفة يدوية تسمى
|
||||
|
||||
`createStore()
|
||||
`
|
||||
```js
|
||||
createStore()
|
||||
```
|
||||
|
||||
حيث يمكنك إنشاء المتجر الذي سيحافظ على كل حالتك.
|
||||
|
||||
@ -29,8 +30,9 @@ Redux هو حاوية حالة يمكن التنبؤ بها لتطبيقات Jav
|
||||
|
||||
#### لا يمكن تغيير الحالة إلا من خلال وظيفة نقية تعرف بالمخفّض حتى نتمكن من إنشاء هذا الاتصال سنمرر في المخفض إلى CreateStore () مثل
|
||||
|
||||
`var store = createStore(reducer)
|
||||
`
|
||||
```js
|
||||
var store = createStore(reducer)
|
||||
```
|
||||
|
||||
يصبح الأمر أكثر تعقيدا عندما يكون لديك مخفضات أكثر ولكن في الصميم ، يحتوي المخزن الآن على مخفض متصل به
|
||||
|
||||
@ -40,20 +42,22 @@ Redux هو حاوية حالة يمكن التنبؤ بها لتطبيقات Jav
|
||||
|
||||
تستطيع أن ترى أين يحدث هذا.
|
||||
|
||||
`store.dispatch(action)
|
||||
`
|
||||
```js
|
||||
store.dispatch(action)
|
||||
```
|
||||
|
||||
قبل أن أتناول ما هو المخفض والعمل الذي أقوم به ، أعتقد أن عرض تطبيق أساسي ومحدود للغاية لـ CreateStore () من Redux سوف يساعد بشكل كبير.
|
||||
|
||||
`createStore = (reducer) => {
|
||||
let state;
|
||||
//dispatch method
|
||||
dispatch = (action) => {
|
||||
state = reducer(state, action)
|
||||
}
|
||||
return {dispatch}
|
||||
}
|
||||
`
|
||||
```js
|
||||
createStore = (reducer) => {
|
||||
let state;
|
||||
//dispatch method
|
||||
dispatch = (action) => {
|
||||
state = reducer(state, action)
|
||||
}
|
||||
return {dispatch}
|
||||
}
|
||||
```
|
||||
|
||||
انظر كيف نمرر في المخفض إلى createStore ويصبح مضبوطًا في طريقة إرسالنا ؛ وعندما نطلق على طريقة الإرسال فإنه يأخذ في عمل ويضع حالة جديدة على أساس ما سوف يعود المخفض.
|
||||
|
||||
@ -61,8 +65,9 @@ Redux هو حاوية حالة يمكن التنبؤ بها لتطبيقات Jav
|
||||
|
||||
الإجراء في المستوى الأساسي هو كائن له خاصية تسمى النوع. يمكن أن يكون لها أيضًا خصائص أخرى ، ولكن ببساطة ستتمتع بالنوع.
|
||||
|
||||
`var someAction = {type:'doSomething'}
|
||||
`
|
||||
```js
|
||||
var someAction = {type:'doSomething'}
|
||||
```
|
||||
|
||||
المخفض هو مجرد وظيفة:
|
||||
|
||||
|
@ -8,8 +8,9 @@ localeTitle: إجراءات Redux
|
||||
|
||||
فمثلا
|
||||
|
||||
`const ADD_ITEM = 'ADD_ITEM'
|
||||
`
|
||||
```javascript
|
||||
const ADD_ITEM = 'ADD_ITEM'
|
||||
```
|
||||
|
||||
`{
|
||||
type: ADD_ITEM,
|
||||
|
@ -51,15 +51,16 @@ Redux Thunk هي برامج وسيطة تسمح لك بإعادة الوظائف
|
||||
|
||||
يمكن تثبيت Redux Thunk باستخدام `npm install redux-thunk --save` أو `yarn add redux-thunk` مع سطر الأوامر. لأنها أداة Redux ، ستحتاج أيضًا إلى إعداد Redux. بمجرد تثبيته ، يتم تمكينه باستخدام `applyMiddleware()` :
|
||||
|
||||
`import { createStore, applyMiddleware } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import rootReducer from './reducers/index';
|
||||
|
||||
const store = createStore(
|
||||
rootReducer,
|
||||
applyMiddleware(thunk)
|
||||
);
|
||||
`
|
||||
```javascript
|
||||
import { createStore, applyMiddleware } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import rootReducer from './reducers/index';
|
||||
|
||||
const store = createStore(
|
||||
rootReducer,
|
||||
applyMiddleware(thunk)
|
||||
);
|
||||
```
|
||||
|
||||
### المراجع
|
||||
|
||||
|
@ -45,8 +45,9 @@ localeTitle: الطبقات والكائنات
|
||||
|
||||
الآن ، لإنشاء مثيل لهذا الفصل ، تحتاج فقط إلى استدعاء الدالة `.new` .
|
||||
|
||||
`mazda3 = Car.new('Mazda', 'Mazda3', 'White')
|
||||
`
|
||||
```Ruby
|
||||
mazda3 = Car.new('Mazda', 'Mazda3', 'White')
|
||||
```
|
||||
|
||||
هذا شيء عظيم ، لكن في بعض الأحيان قد تحتاج إلى تغيير بعض هذه السمات! معظم هذه الصفات في هذا المثال ستكون ثابتة. ومع ذلك ، تخيل أنك قررت الحصول على طلاء جديد. كيف ستذهب حول تحديث حالة هذا الشيء من `Car` ؟
|
||||
|
||||
|
@ -10,96 +10,111 @@ localeTitle: طرق المصفوفة المشتركة
|
||||
|
||||
\`\` \`روبي الصفيف = \[0 ، 1 ، 2 ، 3 ، 4\]
|
||||
|
||||
`#### .length
|
||||
The .length method tallies the number of elements in your array and returns the count:
|
||||
`
|
||||
```
|
||||
#### .length
|
||||
The .length method tallies the number of elements in your array and returns the count:
|
||||
```
|
||||
|
||||
ياقوت array.length => 5
|
||||
|
||||
`#### .first
|
||||
The .first method accesses the first element of the array, the element at index 0:
|
||||
`
|
||||
```
|
||||
#### .first
|
||||
The .first method accesses the first element of the array, the element at index 0:
|
||||
```
|
||||
|
||||
ياقوت array.first => 0
|
||||
|
||||
`#### .last
|
||||
The .last method accesses the last element of the array:
|
||||
`
|
||||
```
|
||||
#### .last
|
||||
The .last method accesses the last element of the array:
|
||||
```
|
||||
|
||||
ياقوت array.last => 4
|
||||
|
||||
`#### .take
|
||||
The .take method returns the first n elements of the array:
|
||||
`
|
||||
```
|
||||
#### .take
|
||||
The .take method returns the first n elements of the array:
|
||||
```
|
||||
|
||||
ياقوت array.take (3) => \[0 ، 1 ، 2\]
|
||||
|
||||
`#### .drop
|
||||
The .drop method returns the elements after n elements of the array:
|
||||
`
|
||||
```
|
||||
#### .drop
|
||||
The .drop method returns the elements after n elements of the array:
|
||||
```
|
||||
|
||||
ياقوت array.drop (3) => \[3 ، 4\]
|
||||
|
||||
`#### array index
|
||||
You can access a specific element in an array by accessing its index. If the index does not exist in the array, nil will be returned:
|
||||
`
|
||||
```
|
||||
#### array index
|
||||
You can access a specific element in an array by accessing its index. If the index does not exist in the array, nil will be returned:
|
||||
```
|
||||
|
||||
ياقوت مجموعة \[2\] => 2
|
||||
|
||||
مجموعة \[5\] => لا شيء
|
||||
|
||||
`#### .pop
|
||||
The .pop method will permantently remove the last element of an array:
|
||||
`
|
||||
```
|
||||
#### .pop
|
||||
The .pop method will permantently remove the last element of an array:
|
||||
```
|
||||
|
||||
ياقوت array.pop => \[0 ، 1 ، 2 ، 3\]
|
||||
|
||||
`#### .shift
|
||||
The .shift method will permantently remove the first element of an array and return this element:
|
||||
`
|
||||
```
|
||||
#### .shift
|
||||
The .shift method will permantently remove the first element of an array and return this element:
|
||||
```
|
||||
|
||||
ياقوت array.shift => 0
|
||||
مجموعة مصفوفة => \[1 ، 2 ، 3 ، 4\]
|
||||
|
||||
`#### .push
|
||||
The .push method will allow you to add an element to the end of an array:
|
||||
`
|
||||
```
|
||||
#### .push
|
||||
The .push method will allow you to add an element to the end of an array:
|
||||
```
|
||||
|
||||
ياقوت array.push (99) => \[0 ، 1 ، 2 ، 3 ، 4 ، 99\]
|
||||
|
||||
`#### .unshift
|
||||
The .unshift method will allow you to add an element to the beginning of an array:
|
||||
`
|
||||
```
|
||||
#### .unshift
|
||||
The .unshift method will allow you to add an element to the beginning of an array:
|
||||
```
|
||||
|
||||
الصفيف = \[2 ، 3\] array.unshift (1) => \[1 ، 2 ، 3\]
|
||||
|
||||
`#### .delete
|
||||
The .delete method removes a specified element from an array permanently:
|
||||
`
|
||||
```
|
||||
#### .delete
|
||||
The .delete method removes a specified element from an array permanently:
|
||||
```
|
||||
|
||||
ياقوت array.delete (1) => \[0 ، 2 ، 3 ، 4\]
|
||||
|
||||
`#### .delete_at
|
||||
The .delete_at method allows you to permanently remove an element of an array at a specified index:
|
||||
`
|
||||
```
|
||||
#### .delete_at
|
||||
The .delete_at method allows you to permanently remove an element of an array at a specified index:
|
||||
```
|
||||
|
||||
ياقوت array.delete\_at (0) => \[1 ، 2 ، 3 ، 4\]
|
||||
|
||||
`#### .reverse
|
||||
The .reverse method reverses the array but does not mutate it (the original array stays as is):
|
||||
`
|
||||
```
|
||||
#### .reverse
|
||||
The .reverse method reverses the array but does not mutate it (the original array stays as is):
|
||||
```
|
||||
|
||||
ياقوت array.reverse => \[4 ، 3 ، 2 ، 1 ، 0\]
|
||||
|
||||
`#### .select
|
||||
The .select method iterates over an array and returns a new array that includes any items that return true to the expression provided.
|
||||
`
|
||||
```
|
||||
#### .select
|
||||
The .select method iterates over an array and returns a new array that includes any items that return true to the expression provided.
|
||||
```
|
||||
|
||||
ياقوت الصفيف = \[1 ، 2 ، 3 ، 4 ، 5 ، 6 ، 7 ، 8 ، 9 ، 10\] array.select {| number | رقم> 4} => \[5 ، 6 ، 7 ، 8 ، 9 ، 10\] مجموعة مصفوفة => \[5 ، 6 ، 7 ، 8 ، 9 ، 10\]
|
||||
|
||||
`#### .include?
|
||||
The include? method checks to see if the argument given is included in the array:
|
||||
`
|
||||
```
|
||||
#### .include?
|
||||
The include? method checks to see if the argument given is included in the array:
|
||||
```
|
||||
|
||||
ياقوت الصفيف = \[1 ، 2 ، 3 ، 4 ، 5\] => \[1 ، 2 ، 3 ، 4 ، 5\] array.include؟ (3) => صحيح
|
||||
|
||||
@ -109,33 +124,38 @@ localeTitle: طرق المصفوفة المشتركة
|
||||
|
||||
\`\` \`روبي صفيف = \[1 ، 2 ، \[3 ، 4 ، 5\] ، \[6 ، 7\]\] array.flatten => \[1 ، 2 ، 3 ، 4 ، 5 ، 6 ، 7\]
|
||||
|
||||
`#### .join
|
||||
The .join method returns a string of all the elements of the array separated by a separator parameter. If the separator parameter is nil, the method uses an empty string as a separator between strings.
|
||||
`
|
||||
```
|
||||
#### .join
|
||||
The .join method returns a string of all the elements of the array separated by a separator parameter. If the separator parameter is nil, the method uses an empty string as a separator between strings.
|
||||
```
|
||||
|
||||
ياقوت array.join => "1234" array.join (" _") => "1_ 2 _3_ 4"
|
||||
|
||||
`#### .each
|
||||
The .each method iterates over each element of the array, allowing you to perform actions on them.
|
||||
`
|
||||
```
|
||||
#### .each
|
||||
The .each method iterates over each element of the array, allowing you to perform actions on them.
|
||||
```
|
||||
|
||||
ياقوت array.each do | element | يضع العنصر النهاية => 0 1 2 3 4
|
||||
|
||||
`#### .map
|
||||
The .map method is the same as the .collect method. The .map and .collect methods iterate over each element of the array, allowing you to perform actions on them. The .map and .collect methods differ from the .each method in that they return an array containing the transformed elements.
|
||||
`
|
||||
```
|
||||
#### .map
|
||||
The .map method is the same as the .collect method. The .map and .collect methods iterate over each element of the array, allowing you to perform actions on them. The .map and .collect methods differ from the .each method in that they return an array containing the transformed elements.
|
||||
```
|
||||
|
||||
ياقوت array.map {| عنصر | العنصر \* 2} يضع العنصر النهاية => 0 2 4 6 8
|
||||
|
||||
`#### .uniq
|
||||
The .uniq method takes in an array containing duplicate elements, and returns a copy of the array containing only unique elements--any duplicate elements are removed from the array.
|
||||
`
|
||||
```
|
||||
#### .uniq
|
||||
The .uniq method takes in an array containing duplicate elements, and returns a copy of the array containing only unique elements--any duplicate elements are removed from the array.
|
||||
```
|
||||
|
||||
ياقوت الصفيف = \[1 ، 1 ، 2 ، 2 ، 3 ، 3 ، 3 ، 4 ، 4 ، 4 ، 4 ، 5 ، 6 ، 7 ، 8\] array.uniq => \[1 ، 2 ، 3 ، 4 ، 5 ، 6 ، 7 ، 8\]
|
||||
|
||||
`#### .concat
|
||||
The .concat method appends the elements from an array to the original array. The .concat method can take in multiple arrays as an argument, which will in turn append multiple arrays to the original array.
|
||||
`
|
||||
```
|
||||
#### .concat
|
||||
The .concat method appends the elements from an array to the original array. The .concat method can take in multiple arrays as an argument, which will in turn append multiple arrays to the original array.
|
||||
```
|
||||
|
||||
ياقوت الصفيف = \[0 ، 1 ، 2 ، 3 ، 4\] array.concat (\[5 ، 6 ، 7\] ، \[8 ، 9 ، 10\]) => \[0 ، 1 ، 2 ، 3 ، 4 ، 5 ، 6 ، 7 ، 8 ، 9 ، 10\] \`\` \`
|
||||
|
||||
|
@ -18,23 +18,24 @@ localeTitle: ياقوت
|
||||
|
||||
إذا كنت غير معتاد على بعض المفاهيم أعلاه ، فاقرأ ، ولا تقلق. يركز روبي على البساطة والإنتاجية من خلال تركيبه الأنيق الذي يكون طبيعيًا للقراءة والكتابة بسهولة ، مثل:
|
||||
|
||||
`# Quick example of Ruby with Object Oriented Programming
|
||||
class Greeter
|
||||
def initialize(name)
|
||||
@name = name.capitalize
|
||||
end
|
||||
|
||||
def salute
|
||||
puts "Hello #{@name}!"
|
||||
end
|
||||
end
|
||||
|
||||
# Create a new object
|
||||
g = Greeter.new("world")
|
||||
|
||||
# Output "Hello World!"
|
||||
g.salute
|
||||
`
|
||||
```ruby
|
||||
# Quick example of Ruby with Object Oriented Programming
|
||||
class Greeter
|
||||
def initialize(name)
|
||||
@name = name.capitalize
|
||||
end
|
||||
|
||||
def salute
|
||||
puts "Hello #{@name}!"
|
||||
end
|
||||
end
|
||||
|
||||
# Create a new object
|
||||
g = Greeter.new("world")
|
||||
|
||||
# Output "Hello World!"
|
||||
g.salute
|
||||
```
|
||||
|
||||
## الإصدار
|
||||
|
||||
|
@ -30,8 +30,9 @@ localeTitle: إدارة إصدارات روبي
|
||||
|
||||
هناك نوعان من الأدوات التي تحظى بشعبية كبيرة ، لكن كلاهما وافق على ذلك مشاركة ملف مشترك. العديد من مشاريع Ruby (أو Rails) ستشمل بسيطة ملف `.ruby-version` ، الذي يحدد ببساطة رقم إصدار ، على _سبيل المثال_ :
|
||||
|
||||
`2.4.2
|
||||
`
|
||||
```
|
||||
2.4.2
|
||||
```
|
||||
|
||||
الأدوات الشائعة لمساعدتك في إدارة إصدار روبي هي:
|
||||
|
||||
@ -46,15 +47,16 @@ localeTitle: إدارة إصدارات روبي
|
||||
|
||||
على سبيل المثال ، قد يكون لديك هذا التسلسل:
|
||||
|
||||
`% cd ~/projects/older-project
|
||||
% ruby --version
|
||||
|
||||
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin16]
|
||||
|
||||
% cd ~/projects/newer-project
|
||||
% ruby --version
|
||||
|
||||
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
|
||||
`
|
||||
```shell
|
||||
% cd ~/projects/older-project
|
||||
% ruby --version
|
||||
|
||||
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin16]
|
||||
|
||||
% cd ~/projects/newer-project
|
||||
% ruby --version
|
||||
|
||||
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
|
||||
```
|
||||
|
||||
(هذه الأمثلة من جهاز MacOS)
|
@ -14,10 +14,11 @@ localeTitle: Rubocop
|
||||
|
||||
يتم تسليم Rubocop كما جوهرة ، لذلك في مشروع نموذجي يستخدم Bundler لك `Gemfile` إلى قسم التطوير في `Gemfile` الخاص بك:
|
||||
|
||||
`group :development do
|
||||
gem rubocop
|
||||
end
|
||||
`
|
||||
```
|
||||
group :development do
|
||||
gem rubocop
|
||||
end
|
||||
```
|
||||
|
||||
وهذا يعني أن أي شخص يستخدم مشروعك سيكون له نفس الإصدار من Rubocop ، و سيتفق الجميع على أفضل الممارسات الحالية.
|
||||
|
||||
@ -25,15 +26,17 @@ localeTitle: Rubocop
|
||||
|
||||
قبل كل التزام ، أرغب في التحقق من أن الشفرة المعدلة حديثًا تتوافق معها معيار commmunity ، ببساطة عن طريق تشغيل:
|
||||
|
||||
`rubocop
|
||||
`
|
||||
```
|
||||
rubocop
|
||||
```
|
||||
|
||||
سيؤدي ذلك إلى إخراج قائمة بالتحذيرات حول شفرتك.
|
||||
|
||||
يمكن أن يكون من المفيد طلب Rubocop للحصول على مزيد من المساعدة:
|
||||
|
||||
`rubocop --extra-details --display-cop-names
|
||||
`
|
||||
```
|
||||
rubocop --extra-details --display-cop-names
|
||||
```
|
||||
|
||||
(يمكنك إضافة هذه الملفات إلى ملف `.rubocop` لجعلها افتراضية.)
|
||||
|
||||
@ -43,20 +46,23 @@ localeTitle: Rubocop
|
||||
|
||||
لنفترض أنني كتبت رمزًا جديدًا ؛ قبل أن ألتزم بها ، قد أقرر ذلك تأكد من أنها تلتزم بالمبادئ التوجيهية:
|
||||
|
||||
`rubocop <my new file>
|
||||
`
|
||||
```shell
|
||||
rubocop <my new file>
|
||||
```
|
||||
|
||||
يمكنني تحرير التغييرات المقترحة يدويًا ، أو يمكنني أن أطلب من Rubocop إصلاحها مشاكل طفيفة تلقائيا:
|
||||
|
||||
`rubocop --auto-correct
|
||||
`
|
||||
```
|
||||
rubocop --auto-correct
|
||||
```
|
||||
|
||||
### تشغيل بعض رجال الشرطة فقط
|
||||
|
||||
يتم تنفيذ كل المبادئ التوجيهية للمجتمع في "شرطي" Rubocop. عند العمل على قاعدة البيانات القديمة قد تغرق مع التحذيرات عند تقديم Rubocop. في هذه الحالة ، يمكن أن يكون من المفيد تشغيل شرطي واحد فقط عبر مصدر البرنامج ، وتحقق من هذه التغييرات قبل الانتقال إلى المبدأ التوجيهي التالي ، من أجل مثال:
|
||||
|
||||
`rubocop --auto-correct --only 'Layout/EmptyLineAfterMagicComment'
|
||||
`
|
||||
```
|
||||
rubocop --auto-correct --only 'Layout/EmptyLineAfterMagicComment'
|
||||
```
|
||||
|
||||
### تكامل محرر النصوص
|
||||
|
||||
|
@ -6,43 +6,50 @@ localeTitle: روبي أرايس
|
||||
|
||||
يمثل الصفيف قائمة بالقيم. غالباً ما تسمى القيم الفردية "عناصر" الصفيف. لإنشاء صفيف في Ruby ، استخدم الأقواس المربعة والقيم المنفصلة باستخدام الفواصل:
|
||||
|
||||
`my_array = [1, 2, 3, 4, 5]
|
||||
`
|
||||
```ruby
|
||||
my_array = [1, 2, 3, 4, 5]
|
||||
```
|
||||
|
||||
المثال الأول هو مجموعة من الأرقام ، لكن مصفوفة Ruby يمكن أن تحتوي على قيم من أنواع مختلفة ، حتى المصفوفات الأخرى:
|
||||
|
||||
`mixed_array = [5, "Hello World", true, [1,2,3]]
|
||||
`
|
||||
```ruby
|
||||
mixed_array = [5, "Hello World", true, [1,2,3]]
|
||||
```
|
||||
|
||||
يمكنك الوصول إلى عناصر صفيف يحتوي على أقواس مربعة وفهارس رقمية. لاحظ أن العنصر الأول في index 0 ، وليس 1:
|
||||
|
||||
`mixed_array[0] # 5
|
||||
mixed_array[1] # "Hello World"
|
||||
mixed_array[2] # true
|
||||
`
|
||||
```ruby
|
||||
mixed_array[0] # 5
|
||||
mixed_array[1] # "Hello World"
|
||||
mixed_array[2] # true
|
||||
```
|
||||
|
||||
يمكنك التحقق من عدد العناصر التي تحتوي عليها المصفوفة باستخدام طريقة `length` :
|
||||
|
||||
`mixed_array.length # 3
|
||||
[].length # 0
|
||||
`
|
||||
```ruby
|
||||
mixed_array.length # 3
|
||||
[].length # 0
|
||||
```
|
||||
|
||||
يمكنك التحقق من العنصر الأول في مصفوفة باستخدام الطريقة `first` :
|
||||
|
||||
`mixed_array.first # 5
|
||||
`
|
||||
```ruby
|
||||
mixed_array.first # 5
|
||||
```
|
||||
|
||||
يمكنك التحقق من آخر عنصر في مصفوفة باستخدام الطريقة `last` :
|
||||
|
||||
`mixed_array.last # true
|
||||
`
|
||||
```ruby
|
||||
mixed_array.last # true
|
||||
```
|
||||
|
||||
#### روبي لامدا
|
||||
|
||||
كما يشار إلى lambda على أنها وظيفة مجهولة. لإنشاء لامدا في Ruby ، يمكنك استخدام البنية التالية:
|
||||
|
||||
`lambda = lambda {}
|
||||
`
|
||||
```ruby
|
||||
lambda = lambda {}
|
||||
```
|
||||
|
||||
#### معلومات اكثر:
|
||||
|
||||
|
@ -8,38 +8,42 @@ localeTitle: روبي التعليقات
|
||||
|
||||
في روبي ، يبدأ تعليق سطر واحد بالحرف `#` ويمتد إلى نهاية السطر. يمكن أن يكون التعليق على السطر الخاص به أو بعد الكود.
|
||||
|
||||
`puts "Learning to code is fun!"
|
||||
|
||||
# I am a single line comment.
|
||||
|
||||
puts "Ruby is a great language!" # Me too - I am a trailing comment.
|
||||
`
|
||||
```Ruby
|
||||
puts "Learning to code is fun!"
|
||||
|
||||
# I am a single line comment.
|
||||
|
||||
puts "Ruby is a great language!" # Me too - I am a trailing comment.
|
||||
```
|
||||
|
||||
عند التنفيذ ، ينتج البرنامج أعلاه ما يلي:
|
||||
|
||||
`Learning to code is fun!
|
||||
Ruby is a great language!
|
||||
`
|
||||
```
|
||||
Learning to code is fun!
|
||||
Ruby is a great language!
|
||||
```
|
||||
|
||||
يمكنك إجراء عدة تعليقات سطر من خلال وضع التعليقات بين `=begin` و `=end` . `=begin` start و `=end` يجب أن تبدأ في بداية السطر ويجب أن يكون `=end` على خط خاص به.
|
||||
|
||||
`=begin
|
||||
I am a multi-line comment
|
||||
and I can be as long as I please.
|
||||
See, still going!
|
||||
=end
|
||||
|
||||
puts "Hello World!"
|
||||
|
||||
=begin It's ok to start the comment on the same
|
||||
line as "=begin" (though it's more readable if
|
||||
you don't) but you can't put a space or any
|
||||
text before "=begin" or "=end" and you can't put
|
||||
anything on the same line after "=end".
|
||||
=end
|
||||
`
|
||||
```ruby
|
||||
=begin
|
||||
I am a multi-line comment
|
||||
and I can be as long as I please.
|
||||
See, still going!
|
||||
=end
|
||||
|
||||
puts "Hello World!"
|
||||
|
||||
=begin It's ok to start the comment on the same
|
||||
line as "=begin" (though it's more readable if
|
||||
you don't) but you can't put a space or any
|
||||
text before "=begin" or "=end" and you can't put
|
||||
anything on the same line after "=end".
|
||||
=end
|
||||
```
|
||||
|
||||
عند التنفيذ ، ينتج البرنامج أعلاه ما يلي:
|
||||
|
||||
`Hello World!
|
||||
`
|
||||
```
|
||||
Hello World!
|
||||
```
|
@ -6,33 +6,39 @@ localeTitle: روبي هاش
|
||||
|
||||
تمثل التجزئة مجموعة من أزواج القيم الرئيسية المميزة. ويسمى أيضا المصفوفات الترابطية. لإنشاء تجزئة في Ruby ، استخدم الأقواس المتعرجة وفصل كل زوج من قيم المفاتيح باستخدام الفاصلة.
|
||||
|
||||
`my_hash = {:key1 => "value", :key2 => "value2"}
|
||||
`
|
||||
```ruby
|
||||
my_hash = {:key1 => "value", :key2 => "value2"}
|
||||
```
|
||||
|
||||
يمكنك إنشاء تجزئة بالطرق التالية
|
||||
|
||||
`my_hash = Hash.new # with empty hash
|
||||
my_hash = {:key1 => "value", :key2 => "value2"} # with key's and value's defined
|
||||
`
|
||||
```ruby
|
||||
my_hash = Hash.new # with empty hash
|
||||
my_hash = {:key1 => "value", :key2 => "value2"} # with key's and value's defined
|
||||
```
|
||||
|
||||
يمكنك الوصول إلى قيمة المفتاح في تجزئة مع الأقواس المربعة والمراجع الرئيسية
|
||||
|
||||
`my_hash[:key1] # value
|
||||
my_hash[:key2] # value2
|
||||
`
|
||||
```ruby
|
||||
my_hash[:key1] # value
|
||||
my_hash[:key2] # value2
|
||||
```
|
||||
|
||||
يمكنك تعيين مفتاح جديد وقيمة لتجزئة محددة بالفعل
|
||||
|
||||
`my_hash[:key3] = "value3" # {:key1=>"value", :key2=>"value2", :key3=>"value3"}
|
||||
`
|
||||
```ruby
|
||||
my_hash[:key3] = "value3" # {:key1=>"value", :key2=>"value2", :key3=>"value3"}
|
||||
```
|
||||
|
||||
يمكنك التحقق من عدد عناصر التجزئة في طريقة `length` :
|
||||
|
||||
`my_hash.length # 2
|
||||
`
|
||||
```ruby
|
||||
my_hash.length # 2
|
||||
```
|
||||
|
||||
يمكنك أيضًا إنشاء أعداد صحيحة كمفتاح هاش ، لكن بناء الجملة يختلف عن الصيغة المعتادة
|
||||
|
||||
`my_hash = {1: "value"} # will raise an exception
|
||||
my_hash = {1 => "value"} # will create hash with corresponding key value pair
|
||||
`
|
||||
```ruby
|
||||
my_hash = {1: "value"} # will raise an exception
|
||||
my_hash = {1 => "value"} # will create hash with corresponding key value pair
|
||||
```
|
@ -6,42 +6,48 @@ localeTitle: روبي هاشز
|
||||
|
||||
التجزئة هي مجموعة من المفاتيح والقيم. يشبه ما يسمى عادةً قاموسًا بلغات أخرى. في روبي ، تشبه التجزئة [صفيفًا](https://raw.githubusercontent.com/freeCodeCamp/guides/master/src/pages/ruby/ruby-arrays/index.md) ، ولكن بدلاً من تخزين قيمة تخزن زوجًا رئيسيًا ذا قيمة.
|
||||
|
||||
`array = ["value"]
|
||||
hash = { "key" => "value" }
|
||||
`
|
||||
```ruby
|
||||
array = ["value"]
|
||||
hash = { "key" => "value" }
|
||||
```
|
||||
|
||||
هناك طريقتان مختلفتان لإنشاء تجزئة جديدة:
|
||||
|
||||
`hash1 = {a: 100, b: "200"}
|
||||
hash2 = Hash.new
|
||||
hash3 = Hash.new(0) # with default value set to 0
|
||||
`
|
||||
```ruby
|
||||
hash1 = {a: 100, b: "200"}
|
||||
hash2 = Hash.new
|
||||
hash3 = Hash.new(0) # with default value set to 0
|
||||
```
|
||||
|
||||
يمكن للمبرمج بعد ذلك الوصول إلى قيمة تجزئة باستخدام مفتاحه ، بدلاً من الفهرس.
|
||||
|
||||
`array[0] # => "value"
|
||||
hash["key"] # => "value"
|
||||
`
|
||||
```ruby
|
||||
array[0] # => "value"
|
||||
hash["key"] # => "value"
|
||||
```
|
||||
|
||||
وبهذه الطريقة ، يعمل تجزئة مثل القاموس حيث يمكنك البحث عن قيمة من خلال مفتاحه.
|
||||
|
||||
`dictionary = { "Aardvark" => "a large, nocturnal, burrowing mammal",
|
||||
"Zyzzyva" => "a genus of tropical weevils" }
|
||||
dictionary["Aardvark"] # => "a large, nocturnal, burrowing mammal"
|
||||
dictionary["Zyzzyva"] # => "a genus of tropical weevils"
|
||||
`
|
||||
```ruby
|
||||
dictionary = { "Aardvark" => "a large, nocturnal, burrowing mammal",
|
||||
"Zyzzyva" => "a genus of tropical weevils" }
|
||||
dictionary["Aardvark"] # => "a large, nocturnal, burrowing mammal"
|
||||
dictionary["Zyzzyva"] # => "a genus of tropical weevils"
|
||||
```
|
||||
|
||||
يمكنك أيضًا إنشاء تجزئة باستخدام [الرموز](#) كمفاتيح.
|
||||
|
||||
`hash = { :symbol => "value" }
|
||||
hash[:symbol] # => "value"
|
||||
`
|
||||
```ruby
|
||||
hash = { :symbol => "value" }
|
||||
hash[:symbol] # => "value"
|
||||
```
|
||||
|
||||
بالإضافة إلى ذلك ، إذا كانت جميع المفاتيح الخاصة بك هي [رموز](#) ، فيمكنك كتابة التجزئة في هذا التنسيق البديل ، ولكن يمكنك الوصول إليها بنفس الطريقة:
|
||||
|
||||
`hash = { symbol: "value" }
|
||||
hash[:symbol] # => "value"
|
||||
`
|
||||
```ruby
|
||||
hash = { symbol: "value" }
|
||||
hash[:symbol] # => "value"
|
||||
```
|
||||
|
||||
#### معلومات اكثر:
|
||||
|
||||
|
@ -16,24 +16,27 @@ localeTitle: طرق روبي
|
||||
|
||||
#### طريقة بسيطة
|
||||
|
||||
`def my_method
|
||||
code goes here
|
||||
end
|
||||
`
|
||||
```
|
||||
def my_method
|
||||
code goes here
|
||||
end
|
||||
```
|
||||
|
||||
#### معلمة قبول الطريقة
|
||||
|
||||
`def my_method (param1, param2)
|
||||
param1 + param2
|
||||
end
|
||||
`
|
||||
```
|
||||
def my_method (param1, param2)
|
||||
param1 + param2
|
||||
end
|
||||
```
|
||||
|
||||
#### طريقة paramter المعرفة مسبقًا (تُستخدم المعلمات المحددة مسبقًا عند عدم تقديم أي منها)
|
||||
|
||||
`def my_method (param1 = parameter1, param2 = parameter2)
|
||||
parm1 + parm2
|
||||
end
|
||||
`
|
||||
```
|
||||
def my_method (param1 = parameter1, param2 = parameter2)
|
||||
parm1 + parm2
|
||||
end
|
||||
```
|
||||
|
||||
## العودة في أساليب
|
||||
|
||||
|
@ -10,8 +10,9 @@ localeTitle: روبي على القضبان
|
||||
|
||||
يتم تنزيل القضبان بنفس الطريقة مثل أي جوهرة روبي أخرى: باستخدام الأمر `gem install` . قبل تنزيله ، سنحتاج إلى [تنزيل Ruby](https://www.ruby-lang.org) . بعد ذلك ، نحن على بعد 3 كلمات فقط من بداية روبي أون ريلز:
|
||||
|
||||
`$ gem install rails
|
||||
`
|
||||
```shell
|
||||
$ gem install rails
|
||||
```
|
||||
|
||||
## إعداد قاعدة البيانات
|
||||
|
||||
@ -21,31 +22,36 @@ localeTitle: روبي على القضبان
|
||||
|
||||
1. بعد تثبيت Ruby on Rails ، من السهل جدًا إنشاء تطبيق جديد تمامًا ، سنحتاج إلى 3 كلمات أخرى:
|
||||
|
||||
`$ rails new your_application_name
|
||||
`
|
||||
```shell
|
||||
$ rails new your_application_name
|
||||
```
|
||||
|
||||
* إذا كنت ترغب في استخدام MySQL `shell $ rails new <application_name> -d mysql`
|
||||
* إذا كنت ترغب في استخدام بوستجرس `shell $ rails new <application_name> -d postgresql`
|
||||
|
||||
1. سيقوم هذا الأمر بإنشاء مجلد _باسم _التطبيق_ الخاص بك_ الذي أبلغته في الأمر الأخير. الخطوة التالية هي الانتقال إلى الدليل الجديد الذي أنشأته للتو:
|
||||
|
||||
`$ cd your_application_name
|
||||
`
|
||||
```shell
|
||||
$ cd your_application_name
|
||||
```
|
||||
|
||||
3. احصل على الجواهر والحزم اللازمة قبل تشغيل التطبيق الخاص بك:
|
||||
|
||||
`$ bundle install
|
||||
`
|
||||
```shell
|
||||
$ bundle install
|
||||
```
|
||||
|
||||
4. لتشغيل خادم سكك الحديد ومعرفة ما إذا كان كل شيء يسير على هذا النحو سريعًا أيضًا:
|
||||
|
||||
`$ rails server
|
||||
`
|
||||
```shell
|
||||
$ rails server
|
||||
```
|
||||
|
||||
لا يمكن أن يكون الأمر بسيطا بعد الآن! حسنًا ، هذا ليس صحيحًا بنسبة 100٪ ، يمكننا جعله أصغر من خلال تقليل أمر `rails server` إلى:
|
||||
|
||||
`$ rails s
|
||||
`
|
||||
```shell
|
||||
$ rails s
|
||||
```
|
||||
|
||||
5. الآن ، مع المتصفح المفضل لديك ، انتقل إلى `http://localhost:3000` وستشاهد: "Yay! أنت على القضبان!"
|
||||
|
||||
|
@ -6,22 +6,25 @@ localeTitle: روبي السلسلة الاستيفاء
|
||||
|
||||
يوفر الاستيفاء سلسلة صيغة أكثر قابلية للقراءة وموجزة لبناء السلاسل. قد تكون على دراية بالتسلسل عبر الطرق `+` أو `<<` :
|
||||
|
||||
`"Hello " + "World!" #=> Hello World
|
||||
"Hello " << "World!" #=> Hello World
|
||||
`
|
||||
```ruby
|
||||
"Hello " + "World!" #=> Hello World
|
||||
"Hello " << "World!" #=> Hello World
|
||||
```
|
||||
|
||||
يوفر الاستيفاء سلسلة طريقة لتضمين رمز Ruby مباشرة في سلسلة:
|
||||
|
||||
`place = "World"
|
||||
"Hello #{place}!" #=> Hello World!
|
||||
|
||||
"4 + 4 is #{4 + 4}" #=> 4 + 4 is 8
|
||||
`
|
||||
```ruby
|
||||
place = "World"
|
||||
"Hello #{place}!" #=> Hello World!
|
||||
|
||||
"4 + 4 is #{4 + 4}" #=> 4 + 4 is 8
|
||||
```
|
||||
|
||||
يتم تقييم كل شيء بين `#{` و `}` برمز روبي. للقيام بذلك ، يجب أن يكون محاطًا بالسلسلة علامات اقتباس مزدوجة ( `"` ).
|
||||
|
||||
ستقوم علامات الاقتباس المفردة بإرجاع السلسلة الصحيحة داخل علامات الاقتباس:
|
||||
|
||||
`place = "World"
|
||||
'Hello #{place}!' #=> Hello #{place}!
|
||||
`
|
||||
```ruby
|
||||
place = "World"
|
||||
'Hello #{place}!' #=> Hello #{place}!
|
||||
```
|
@ -92,8 +92,9 @@ _لاحظ أن الحرف الأول يتم تكبيره فقط إذا كان ف
|
||||
|
||||
* يستبدل `gsub` كل مرجع للمعلمة الأولى للمعلمة الثانية في سلسلة.
|
||||
|
||||
`"ruby is cool".gsub("cool", "very cool") #=> "ruby is very cool"
|
||||
`
|
||||
```ruby
|
||||
"ruby is cool".gsub("cool", "very cool") #=> "ruby is very cool"
|
||||
```
|
||||
|
||||
* يقبل `gsub` أيضًا الأنماط (مثل _regexp_ ) كمعلمة أولى ، مما يسمح بأشياء مثل:
|
||||
|
||||
|
@ -10,22 +10,23 @@ localeTitle: روبي الرموز
|
||||
|
||||
على سبيل المثال: إذا كان Fred ثابتًا في سياق واحد ، وطريقة في أخرى ، وفئة في الثلث ، فسيكون الرمز: Fred هو نفس الكائن في جميع السياقات الثلاثة.
|
||||
|
||||
`module One
|
||||
class Fred
|
||||
end
|
||||
$f1 = :Fred
|
||||
end
|
||||
module Two
|
||||
Fred = 1
|
||||
$f2 = :Fred
|
||||
end
|
||||
def Fred()
|
||||
end
|
||||
$f3 = :Fred
|
||||
$f1.object_id #=> 2514190
|
||||
$f2.object_id #=> 2514190
|
||||
$f3.object_id #=> 2514190
|
||||
`
|
||||
```ruby
|
||||
module One
|
||||
class Fred
|
||||
end
|
||||
$f1 = :Fred
|
||||
end
|
||||
module Two
|
||||
Fred = 1
|
||||
$f2 = :Fred
|
||||
end
|
||||
def Fred()
|
||||
end
|
||||
$f3 = :Fred
|
||||
$f1.object_id #=> 2514190
|
||||
$f2.object_id #=> 2514190
|
||||
$f3.object_id #=> 2514190
|
||||
```
|
||||
|
||||
## العمل مع الرموز
|
||||
|
||||
@ -33,31 +34,34 @@ localeTitle: روبي الرموز
|
||||
|
||||
حتى الآن رأيناهم كمفتاح في هاش (العمل مع الزنانير في روبي):
|
||||
|
||||
`person = {:name => "Philip"}
|
||||
`
|
||||
```ruby
|
||||
person = {:name => "Philip"}
|
||||
```
|
||||
|
||||
لذا ، فإن أول شيء يمكننا القيام به هو فحص الرمز لمعرفة الفئة التي يستخدمها:
|
||||
|
||||
`:hello.class
|
||||
=> Symbol
|
||||
|
||||
"hello".class
|
||||
=> String
|
||||
`
|
||||
```ruby
|
||||
:hello.class
|
||||
=> Symbol
|
||||
|
||||
"hello".class
|
||||
=> String
|
||||
```
|
||||
|
||||
حتى يمكننا أن نرى أن الرموز والسلاسل هي أمثلة لكائنين مختلفين.
|
||||
|
||||
يمكنك الاتصال بأساليب شبيهة `upcase` ، مثل `upcase` ، و `downcase` ، `capitalize` الرموز:
|
||||
|
||||
`:hello.upcase
|
||||
=> :HELLO
|
||||
|
||||
:HELLO.downcase
|
||||
=> :hello
|
||||
|
||||
:hello.capitalize
|
||||
=> :Hello
|
||||
`
|
||||
```ruby
|
||||
:hello.upcase
|
||||
=> :HELLO
|
||||
|
||||
:HELLO.downcase
|
||||
=> :hello
|
||||
|
||||
:hello.capitalize
|
||||
=> :Hello
|
||||
```
|
||||
|
||||
## لماذا تستخدم رمزًا بدلاً من سلسلة؟
|
||||
|
||||
@ -89,16 +93,17 @@ localeTitle: روبي الرموز
|
||||
|
||||
فمثلا:
|
||||
|
||||
`philip".object_id
|
||||
=> 70288511587360
|
||||
"philip".object_id
|
||||
=> 70288504327720
|
||||
|
||||
:philip.object_id
|
||||
=> 539368
|
||||
:philip.object_id
|
||||
=> 539368
|
||||
`
|
||||
```ruby
|
||||
philip".object_id
|
||||
=> 70288511587360
|
||||
"philip".object_id
|
||||
=> 70288504327720
|
||||
|
||||
:philip.object_id
|
||||
=> 539368
|
||||
:philip.object_id
|
||||
=> 539368
|
||||
```
|
||||
|
||||
عند إنشاء كائنين سلسلة بنفس القيمة ، يتم التعامل مع هذين العنصرين ككائنين مختلفين. عند إنشاء رمز ، سيستخدم الرجوع إلى الرمز دائمًا نفس الكائن.
|
||||
|
||||
@ -108,14 +113,15 @@ localeTitle: روبي الرموز
|
||||
|
||||
all\_symbols => نقر المصفوفة لتبديل المصدر لإرجاع مجموعة من الرموز الموجودة حاليًا في جدول رمز Ruby.
|
||||
|
||||
`Symbol.all_symbols.size #=> 903
|
||||
Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
|
||||
:chown, :EOFError, :$;, :String,
|
||||
:LOCK_SH, :"setuid?", :$<,
|
||||
:default_proc, :compact, :extend,
|
||||
:Tms, :getwd, :$=, :ThreadGroup,
|
||||
:wait2, :$>]
|
||||
`
|
||||
```ruby
|
||||
Symbol.all_symbols.size #=> 903
|
||||
Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
|
||||
:chown, :EOFError, :$;, :String,
|
||||
:LOCK_SH, :"setuid?", :$<,
|
||||
:default_proc, :compact, :extend,
|
||||
:Tms, :getwd, :$=, :ThreadGroup,
|
||||
:wait2, :$>]
|
||||
```
|
||||
|
||||
#### معلومات اكثر:
|
||||
|
||||
|
@ -8,10 +8,11 @@ localeTitle: مرحبا بالعالم
|
||||
|
||||
بعد إنشاء `main.rs` ، قم بإضافة التعليمة البرمجية التالية داخل:
|
||||
|
||||
`fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
`
|
||||
```rust
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
```
|
||||
|
||||
نجاح باهر كان ذلك سهلاً ، أليس كذلك؟ داخل الملف `main.rs` الجديد ، ما يلي صحيح:
|
||||
|
||||
@ -20,14 +21,16 @@ localeTitle: مرحبا بالعالم
|
||||
|
||||
لتنفيذ البرنامج ، يجب عليك أولاً تجميعه:
|
||||
|
||||
`$ rustc main.rs
|
||||
`
|
||||
```bash
|
||||
$ rustc main.rs
|
||||
```
|
||||
|
||||
ستقوم هذه العملية بإنشاء ملف قابل للتنفيذ في نفس الدليل ، والذي يمكنك بعد ذلك تشغيله:
|
||||
|
||||
`$ ./main
|
||||
Hello, world!
|
||||
`
|
||||
```bash
|
||||
$ ./main
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
تهانينا! لقد كتبت للتو برنامج الصدأ الخاص بك!
|
||||
|
||||
|
@ -20,8 +20,9 @@ Rust هي لغة برمجة أنظمة تركز على ثلاثة أهداف: ا
|
||||
|
||||
إذا كنت تستخدم نظام التشغيل Linux أو Mac ، فمن الأفضل إجراء عملية تثبيت `rustup` من خلال المحطة الطرفية:
|
||||
|
||||
`$ curl https://sh.rustup.rs -sSf | sh
|
||||
`
|
||||
```bash
|
||||
$ curl https://sh.rustup.rs -sSf | sh
|
||||
```
|
||||
|
||||
سيقوم هذا بتنزيل وتشغيل برنامج نصي على جهازك يقوم بتثبيت الأداة. يضيف برنامج التثبيت تلقائيًا خاصية Rust إلى نظام `PATH` بعد تسجيل الدخول التالي.
|
||||
|
||||
@ -33,8 +34,9 @@ Rust هي لغة برمجة أنظمة تركز على ثلاثة أهداف: ا
|
||||
|
||||
بمجرد تثبيت `rustup` ، يكون التحديث إلى إصدارات أحدث بسيطًا. كل ما تحتاجه للتشغيل هو:
|
||||
|
||||
`$ rustup update
|
||||
`
|
||||
```bash
|
||||
$ rustup update
|
||||
```
|
||||
|
||||
لعرض رقم الإصدار الحالي ، والتزام التجزئة ، وتاريخ التزام مترجم الصدأ ، قم بتشغيل الأمر التالي:
|
||||
|
||||
@ -46,5 +48,6 @@ Rust هي لغة برمجة أنظمة تركز على ثلاثة أهداف: ا
|
||||
|
||||
إلغاء تثبيت الصدأ من النظام سهل كما هو مثبت عليه:
|
||||
|
||||
`$ rustup self uninstall
|
||||
`
|
||||
```bash
|
||||
$ rustup self uninstall
|
||||
```
|
@ -12,12 +12,13 @@ localeTitle: الحلقات
|
||||
|
||||
في ما يلي مثال على برنامج باستخدام `loop` لطباعة الكلمة "مرة أخرى" باستمرار إلى المحطة:
|
||||
|
||||
`fn main() {
|
||||
loop {
|
||||
println!("again!");
|
||||
}
|
||||
}
|
||||
`
|
||||
```rust
|
||||
fn main() {
|
||||
loop {
|
||||
println!("again!");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## حلقات شرطية مع `while`
|
||||
|
||||
@ -25,15 +26,16 @@ localeTitle: الحلقات
|
||||
|
||||
في ما يلي مثال لبرنامج يستخدم `while` العد التنازلي من 5:
|
||||
|
||||
`fn main() {
|
||||
let mut number = 5;
|
||||
|
||||
while number != 0 {
|
||||
println!("{}", number);
|
||||
number = number - 1;
|
||||
}
|
||||
}
|
||||
`
|
||||
```rust
|
||||
fn main() {
|
||||
let mut number = 5;
|
||||
|
||||
while number != 0 {
|
||||
println!("{}", number);
|
||||
number = number - 1;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
قم بتشغيل الكود [هنا](https://play.rust-lang.org/?gist=62677371a8590be27c84dcae7068de57&version=stable) .
|
||||
|
||||
@ -43,14 +45,15 @@ localeTitle: الحلقات
|
||||
|
||||
هنا هو برنامج سبيل المثال أن يطبع كل رقم في صفيف إلى المحطة باستخدام `for` :
|
||||
|
||||
`fn main() {
|
||||
let collection = [15, 7, 2, 6, 9];
|
||||
|
||||
for element in collection.iter() {
|
||||
println!("the value is: {}", element);
|
||||
}
|
||||
}
|
||||
`
|
||||
```rust
|
||||
fn main() {
|
||||
let collection = [15, 7, 2, 6, 9];
|
||||
|
||||
for element in collection.iter() {
|
||||
println!("the value is: {}", element);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
قم بتشغيل الكود [هنا](https://play.rust-lang.org/?gist=0c2acf21b96a81ebd411e4a7dc5a19fd&version=stable) .
|
||||
|
||||
|
@ -64,42 +64,46 @@ localeTitle: بروتوكول OAuth2
|
||||
|
||||
طلب تفويض
|
||||
|
||||
`GET /oauth2/authorize?response_type=code
|
||||
&client_id=client123&scope=profile
|
||||
&redirect_uri=https://client.com/callback HTTP/1.1
|
||||
Host: auth.server.com
|
||||
`
|
||||
```
|
||||
GET /oauth2/authorize?response_type=code
|
||||
&client_id=client123&scope=profile
|
||||
&redirect_uri=https://client.com/callback HTTP/1.1
|
||||
Host: auth.server.com
|
||||
```
|
||||
|
||||
`HTTP/1.1 302 Found
|
||||
Location: https://client.com/callback#code=sb8s6doy9bsd9sd&state=abcde
|
||||
`
|
||||
```
|
||||
HTTP/1.1 302 Found
|
||||
Location: https://client.com/callback#code=sb8s6doy9bsd9sd&state=abcde
|
||||
```
|
||||
|
||||
بعد تلقي رمز التفويض ، تقديم طلب خادم التفويض مع رمز ،
|
||||
|
||||
`POST /oauth2/token HTTP/1.1
|
||||
Host: auth.server.com
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
grant_type=authorization_code
|
||||
&code=sb8s6doy9bsd9sd
|
||||
&redirect_uri=https://client.com/callback
|
||||
&client_id=client123
|
||||
&client_secret=secret
|
||||
&scope=profile
|
||||
`
|
||||
```
|
||||
POST /oauth2/token HTTP/1.1
|
||||
Host: auth.server.com
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
grant_type=authorization_code
|
||||
&code=sb8s6doy9bsd9sd
|
||||
&redirect_uri=https://client.com/callback
|
||||
&client_id=client123
|
||||
&client_secret=secret
|
||||
&scope=profile
|
||||
```
|
||||
|
||||
استجابة
|
||||
|
||||
`HTTP/1.1 200 OK
|
||||
Content-Type: application/json;charset=UTF-8
|
||||
Cache-Control: no-store
|
||||
Pragma: no-cache
|
||||
{
|
||||
"access_token":"gsi8d6fosb9d6fos6df",
|
||||
"token_type":"bearer",
|
||||
"expires_in":3600
|
||||
}
|
||||
`
|
||||
```
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json;charset=UTF-8
|
||||
Cache-Control: no-store
|
||||
Pragma: no-cache
|
||||
{
|
||||
"access_token":"gsi8d6fosb9d6fos6df",
|
||||
"token_type":"bearer",
|
||||
"expires_in":3600
|
||||
}
|
||||
```
|
||||
|
||||
#### التدفق الضمني
|
||||
|
||||
@ -115,15 +119,17 @@ localeTitle: بروتوكول OAuth2
|
||||
|
||||
نموذج الكود:
|
||||
|
||||
`GET /oauth2/authorize?response_type=token
|
||||
&client_id=client123
|
||||
&redirect_uri=https://client.com/callback HTTP/1.1
|
||||
Host: auth.server.com
|
||||
`
|
||||
```
|
||||
GET /oauth2/authorize?response_type=token
|
||||
&client_id=client123
|
||||
&redirect_uri=https://client.com/callback HTTP/1.1
|
||||
Host: auth.server.com
|
||||
```
|
||||
|
||||
`HTTP/1.1 302 Found
|
||||
Location: https://client.com/callback#access_token=98y2b38&token_type=bearer&expires_in=3600&state=abcde
|
||||
`
|
||||
```
|
||||
HTTP/1.1 302 Found
|
||||
Location: https://client.com/callback#access_token=98y2b38&token_type=bearer&expires_in=3600&state=abcde
|
||||
```
|
||||
|
||||
#### بيانات اعتماد مالك المورد
|
||||
|
||||
@ -139,14 +145,15 @@ localeTitle: بروتوكول OAuth2
|
||||
|
||||
نموذج الكود:
|
||||
|
||||
`POST /oauth2/token HTTP/1.1
|
||||
Host: auth.server.com
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
grant_type=password
|
||||
&username=john
|
||||
&password=abcde
|
||||
`
|
||||
```
|
||||
POST /oauth2/token HTTP/1.1
|
||||
Host: auth.server.com
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
grant_type=password
|
||||
&username=john
|
||||
&password=abcde
|
||||
```
|
||||
|
||||
#### بيانات اعتماد العميل التدفق
|
||||
|
||||
@ -162,14 +169,15 @@ localeTitle: بروتوكول OAuth2
|
||||
|
||||
نموذج الكود:
|
||||
|
||||
`POST /oauth2/token HTTP/1.1
|
||||
Host: auth.server.com
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
grant_type=client_credentials
|
||||
&client_id=client123
|
||||
&client_secret=xyz123
|
||||
`
|
||||
```
|
||||
POST /oauth2/token HTTP/1.1
|
||||
Host: auth.server.com
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
grant_type=client_credentials
|
||||
&client_id=client123
|
||||
&client_secret=xyz123
|
||||
```
|
||||
|
||||
### المراجع
|
||||
|
||||
|
@ -12,33 +12,36 @@ _(يتم كتابة القصاصات التالية في C # لـ MySQL ، لك
|
||||
|
||||
### المشكلة
|
||||
|
||||
`public void RetrieveEmployeeInfo(string username)
|
||||
{
|
||||
using (var connection = new MySqlConnection("valid_connection_string"))
|
||||
{
|
||||
var query = "SELECT * FROM EMPLOYEES WHERE USERNAME = '" + username + "'";
|
||||
|
||||
using (var command = new MySqlCommand(query, connection))
|
||||
{
|
||||
var reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
// do something with the results of your query, like display the employee
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
```csharp
|
||||
public void RetrieveEmployeeInfo(string username)
|
||||
{
|
||||
using (var connection = new MySqlConnection("valid_connection_string"))
|
||||
{
|
||||
var query = "SELECT * FROM EMPLOYEES WHERE USERNAME = '" + username + "'";
|
||||
|
||||
using (var command = new MySqlCommand(query, connection))
|
||||
{
|
||||
var reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
// do something with the results of your query, like display the employee
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
للوهلة الأولى ، قد يبدو ذلك غير مؤذٍ. إذا قام المستخدم بكتابة "JDOE" في برنامجك ، وتم تمريره إلى هذه الوظيفة ، فسوف ينتهي بك الأمر تنفيذ استعلام كالتالي:
|
||||
|
||||
`SELECT * FROM EMPLOYEES WHERE USERNAME = 'JDOE';
|
||||
`
|
||||
```sql
|
||||
SELECT * FROM EMPLOYEES WHERE USERNAME = 'JDOE';
|
||||
```
|
||||
|
||||
تصبح المشكلة أكثر وضوحًا عندما تفكر في ما يحدث إذا _لم يقم_ المستخدم بكتابة ما تتوقعه. ماذا لو `JDOE'; DROP TABLE EMPLOYEES; --` شيئًا مثل `JDOE'; DROP TABLE EMPLOYEES; --` ؟ تبدو سلسلة "طلب البحث" الآن مثل هذه ، والتي ستحدد معلومات الموظف ، ثم تحذف جدول EMPLOYEES بأكمله!
|
||||
|
||||
`SELECT * FROM EMPLOYEES WHERE USERNAME = 'JDOE'; DROP TABLE EMPLOYEES; --'
|
||||
`
|
||||
```sql
|
||||
SELECT * FROM EMPLOYEES WHERE USERNAME = 'JDOE'; DROP TABLE EMPLOYEES; --'
|
||||
```
|
||||
|
||||
### الحل
|
||||
|
||||
@ -66,7 +69,8 @@ _(يتم كتابة القصاصات التالية في C # لـ MySQL ، لك
|
||||
|
||||
الآن ما يحدث إذا كان المستخدم `JDOE'; DROP TABLE EMPLOYEES; --` في `JDOE'; DROP TABLE EMPLOYEES; --` ؟ وينتهي برنامجنا بتنفيذ استعلام مثل هذا ، والعثور على أي موظف اسمه الحقيقي يطابق هذا الإدخال ، ببساطة إرجاع أية سجلات.
|
||||
|
||||
`SELECT * FROM EMPLOYEES WHERE USERNAME = 'JDOE\'; DROP TABLE EMPLOYEES; --'
|
||||
`
|
||||
```sql
|
||||
SELECT * FROM EMPLOYEES WHERE USERNAME = 'JDOE\'; DROP TABLE EMPLOYEES; --'
|
||||
```
|
||||
|
||||
بغض النظر عن اللغة أو قاعدة البيانات التي تستخدمها ، إذا كنت تفكر في الاستعلام عن قاعدة البيانات باستخدام مدخلات المستخدم ، فتحقق من الوثائق لمعرفة الطريقة المناسبة لإضفاء طابع المعلمة على الاستعلامات.
|
@ -45,23 +45,25 @@ localeTitle: مسح
|
||||
|
||||
فمثلا:
|
||||
|
||||
`ping <target_ip_address> -c <number_of_packets_to_send>
|
||||
ping 10.10.0.1 -c 4
|
||||
`
|
||||
```
|
||||
ping <target_ip_address> -c <number_of_packets_to_send>
|
||||
ping 10.10.0.1 -c 4
|
||||
```
|
||||
|
||||
إذا كان النظام الهدف على قيد الحياة ، يجب أن تحصل على رد ظهر يبدو مشابهاً أدناه.
|
||||
|
||||
`Pinging 10.10.0.1 with 32 bytes of data:
|
||||
|
||||
Reply from 10.0.0.1: bytes=32 time=26ms TTL=240
|
||||
Reply from 10.0.0.1: bytes=32 time=26ms TTL=240
|
||||
Reply from 10.0.0.1: bytes=32 time=26ms TTL=240
|
||||
Reply from 10.0.0.1: bytes=32 time=26ms TTL=240
|
||||
Ping statistics for 10.10.0.1:
|
||||
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
|
||||
Approximate round trip times in milliseconds:
|
||||
Minimum = 26ms, Maximum = 26ms, Average = 26ms
|
||||
`
|
||||
```
|
||||
Pinging 10.10.0.1 with 32 bytes of data:
|
||||
|
||||
Reply from 10.0.0.1: bytes=32 time=26ms TTL=240
|
||||
Reply from 10.0.0.1: bytes=32 time=26ms TTL=240
|
||||
Reply from 10.0.0.1: bytes=32 time=26ms TTL=240
|
||||
Reply from 10.0.0.1: bytes=32 time=26ms TTL=240
|
||||
Ping statistics for 10.10.0.1:
|
||||
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
|
||||
Approximate round trip times in milliseconds:
|
||||
Minimum = 26ms, Maximum = 26ms, Average = 26ms
|
||||
```
|
||||
|
||||
* يشير **الرد من** أن حزمة طلب ارتداد ICMP الخاصة بنا قد تم استلامها في حزمة رد ICMP Echo تم إرسالها مرة أخرى.
|
||||
* **Bytes = 32** يخبرنا أن حجم الحزمة التي تم إرسالها.
|
||||
|
@ -20,11 +20,12 @@ localeTitle: إخفاء المعلومات
|
||||
|
||||
قد يبدأ بشيء مثل:
|
||||
|
||||
`10010101 00001101 11001001
|
||||
10010110 00001111 11001010
|
||||
10011111 00010000 11001011
|
||||
...
|
||||
`
|
||||
```
|
||||
10010101 00001101 11001001
|
||||
10010110 00001111 11001010
|
||||
10011111 00010000 11001011
|
||||
...
|
||||
```
|
||||
|
||||
ويطلق على أبسط طريقة لإخفاء البيانات داخل ملف الصورة إدخالاً بتات أقل دلالة (LSB). في هذه الطريقة ، يمكننا أخذ التمثيل الثنائي _للبيانات_ المخفية _والكتابة فوق LSB لكل بايت داخل_ صورة _الغلاف_ . إذا كنا نستخدم ألوان 24 بت ، فإن مقدار التغيير سيكون ضئيلاً ولا يمكن تمييزه عن العين البشرية.
|
||||
|
||||
|
@ -62,28 +62,31 @@ UI الدلالي `1.x` صدر لأول مرة في نوفمبر 2014 مع كس
|
||||
|
||||
في دليل المشروع الخاص بك ، قم بتثبيت gulp عالميًا باستخدام npm
|
||||
|
||||
`npm install -g gulp
|
||||
`
|
||||
```
|
||||
npm install -g gulp
|
||||
```
|
||||
|
||||
تثبيت واجهة المستخدم الدلالية
|
||||
|
||||
`npm install semantic-ui --save
|
||||
cd semantic/
|
||||
gulp build
|
||||
`
|
||||
```
|
||||
npm install semantic-ui --save
|
||||
cd semantic/
|
||||
gulp build
|
||||
```
|
||||
|
||||
تضمين في HTML
|
||||
|
||||
`
|
||||
<link rel="stylesheet" type="text/css" href="semantic/dist/semantic.min.css">
|
||||
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
|
||||
<script src="semantic/dist/semantic.min.js"></script>
|
||||
`
|
||||
```html
|
||||
<link rel="stylesheet" type="text/css" href="semantic/dist/semantic.min.css">
|
||||
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
|
||||
<script src="semantic/dist/semantic.min.js"></script>
|
||||
```
|
||||
|
||||
تحديث عن طريق npm
|
||||
|
||||
`npm update
|
||||
`
|
||||
```
|
||||
npm update
|
||||
```
|
||||
|
||||
3. **التكامل مع الأطر الأخرى**
|
||||
|
||||
|
@ -16,15 +16,17 @@ localeTitle: أزرار واجهة المستخدم الدلالية
|
||||
|
||||
معيار واجهة المستخدم الدلالي زر
|
||||
|
||||
`<button class="ui button">Standard Button</button>
|
||||
`
|
||||
```
|
||||
<button class="ui button">Standard Button</button>
|
||||
```
|
||||
|
||||
* التركيز على زر
|
||||
|
||||
زر مع مستوى مختلف من التركيز
|
||||
|
||||
`<button class="ui primary button">
|
||||
`
|
||||
```
|
||||
<button class="ui primary button">
|
||||
```
|
||||
|
||||
تعتبر فئات التركيز الأخرى `secondary` `positive` `negative`
|
||||
|
||||
@ -32,11 +34,12 @@ localeTitle: أزرار واجهة المستخدم الدلالية
|
||||
|
||||
زر مع الرسوم المتحركة ، تظهر محتويات مخفية
|
||||
|
||||
`<div class="ui animated fade button" tabindex="0">
|
||||
<div class="visible content">Sign-up for a Pro account</div>
|
||||
<div class="hidden content">$12.99 a month</div>
|
||||
</div>
|
||||
`
|
||||
```
|
||||
<div class="ui animated fade button" tabindex="0">
|
||||
<div class="visible content">Sign-up for a Pro account</div>
|
||||
<div class="hidden content">$12.99 a month</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
خاصية `tabindex="0"` أعلاه تجعل لوحة مفاتيح الأزرار `tabindex="0"` ، حيث أن العلامة `<button>` لم يتم استخدامها.
|
||||
|
||||
@ -44,11 +47,12 @@ localeTitle: أزرار واجهة المستخدم الدلالية
|
||||
|
||||
زر بجانب علامة
|
||||
|
||||
`<div class="ui labeled button" tabindex="0">
|
||||
<div class="ui button"><i class="heart icon"></i> Like</div>
|
||||
<a class="ui basic label">2,048</a>
|
||||
</div>
|
||||
`
|
||||
```
|
||||
<div class="ui labeled button" tabindex="0">
|
||||
<div class="ui button"><i class="heart icon"></i> Like</div>
|
||||
<a class="ui basic label">2,048</a>
|
||||
</div>
|
||||
```
|
||||
|
||||
يتم استخدام العنصر `<i>` لتحديد رمز ، هنا هو رمز قلب `<i class="heart icon"></i>` إلى جانب العلامة الأساسية `<a class="ui basic label">2,048</a>`
|
||||
|
||||
@ -56,10 +60,11 @@ localeTitle: أزرار واجهة المستخدم الدلالية
|
||||
|
||||
يمكن أن يكون زر واجهة المستخدم الدلالية مجرد رمز
|
||||
|
||||
`<button class="ui icon button">
|
||||
<i class="camera icon"></i>
|
||||
</button>
|
||||
`
|
||||
```
|
||||
<button class="ui icon button">
|
||||
<i class="camera icon"></i>
|
||||
</button>
|
||||
```
|
||||
|
||||
ما سبق هو مجرد رمز الكاميرا
|
||||
|
||||
@ -67,37 +72,41 @@ localeTitle: أزرار واجهة المستخدم الدلالية
|
||||
|
||||
يمكن أن توجد أزرار واجهة المستخدم الدلالية في مجموعة
|
||||
|
||||
`<div class="ui buttons">
|
||||
<button class="ui button">One</button>
|
||||
<button class="ui button">Two</button>
|
||||
<button class="ui button">Three</button>
|
||||
</div>
|
||||
`
|
||||
```
|
||||
<div class="ui buttons">
|
||||
<button class="ui button">One</button>
|
||||
<button class="ui button">Two</button>
|
||||
<button class="ui button">Three</button>
|
||||
</div>
|
||||
```
|
||||
|
||||
#### يحتوى
|
||||
|
||||
يمكن أن تحتوي أزرار واجهة المستخدم الدلالية على شرطية
|
||||
|
||||
`<div class="ui buttons">
|
||||
<button class="ui positive button">Yes</button>
|
||||
<div class="or" data-text="or"></div>
|
||||
<button class="ui negative button">No</button>
|
||||
</div>
|
||||
`
|
||||
```
|
||||
<div class="ui buttons">
|
||||
<button class="ui positive button">Yes</button>
|
||||
<div class="or" data-text="or"></div>
|
||||
<button class="ui negative button">No</button>
|
||||
</div>
|
||||
```
|
||||
|
||||
#### تنص على
|
||||
|
||||
يمكن أن توجد أزرار واجهة المستخدم الدلالية في حالات مختلفة ، `active` ، `disabled` ، `loading` . ببساطة إضافة اسم الدولة إلى `class` سمة `of` \`العنصر.
|
||||
|
||||
`<button class="ui loading button">Loading</button>
|
||||
`
|
||||
```
|
||||
<button class="ui loading button">Loading</button>
|
||||
```
|
||||
|
||||
#### الاختلافات
|
||||
|
||||
توجد أزرار UI الدلالي في مجموعة متنوعة من الأحجام، `mini` ، `tiny` ، `small` ، `medium` ، `large` ، `big` ، `huge` ، و `massive` .
|
||||
|
||||
`<button class="ui massive button">Massive Button</button>
|
||||
`
|
||||
```
|
||||
<button class="ui massive button">Massive Button</button>
|
||||
```
|
||||
|
||||
هناك الكثير حول أزرار UI الدلالية ، قم بزيارة الرابط المقدم في قسم "مزيد من المعلومات" لمعرفة المزيد.
|
||||
|
||||
|
@ -8,62 +8,63 @@ localeTitle: باني
|
||||
|
||||
هنا مثال على تنفيذ Builder Pattern في Python3.
|
||||
|
||||
`# Builder
|
||||
class CourseBuilder(object):
|
||||
def __init__(self, teacher):
|
||||
self.teacher = teacher
|
||||
|
||||
def build_course(self):
|
||||
self.teacher.provide_homework()
|
||||
self.teacher.provide_exam()
|
||||
return self.teacher.course
|
||||
|
||||
# Teacher
|
||||
class Teacher(object):
|
||||
def __init__(self, name=None):
|
||||
self.name = name
|
||||
self.course = Course()
|
||||
|
||||
def provide_homework(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def provide_exam(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class MathTeacher(Teacher):
|
||||
def provide_homework(self):
|
||||
self.course.homework = 'This is Math homework provided by {}.'.format(self.name)
|
||||
|
||||
def provide_exam(self):
|
||||
self.course.exam = 'This is Math exam tested by {}.'.format(self.name)
|
||||
|
||||
|
||||
class HistoryTeacher(Teacher):
|
||||
def provide_homework(self):
|
||||
self.course.homework = 'This is History homework provided by {}.'.format(self.name)
|
||||
|
||||
def provide_exam(self):
|
||||
self.course.exam = 'This is History exam tested by {}.'.format(self.name)
|
||||
|
||||
|
||||
# Target objects to be produced
|
||||
class Course(object):
|
||||
def __init__(self):
|
||||
self.homework = None
|
||||
self.exam = None
|
||||
|
||||
def __str__(self):
|
||||
return 'Homework: {}\nExam: {}\n'.format(self.homework, self.exam)
|
||||
|
||||
|
||||
math_course = CourseBuilder(MathTeacher('Harry')).build_course()
|
||||
print(math_course)
|
||||
>>> Homework: This is Math homework provided by Harry.
|
||||
>>> Exam: This is Math exam tested by Harry.
|
||||
|
||||
history_course = CourseBuilder(HistoryTeacher('Potter')).build_course()
|
||||
print(history_course)
|
||||
>>> Homework: This is History homework provided by Potter.
|
||||
>>> Exam: This is History exam tested by Potter.
|
||||
`
|
||||
```python
|
||||
# Builder
|
||||
class CourseBuilder(object):
|
||||
def __init__(self, teacher):
|
||||
self.teacher = teacher
|
||||
|
||||
def build_course(self):
|
||||
self.teacher.provide_homework()
|
||||
self.teacher.provide_exam()
|
||||
return self.teacher.course
|
||||
|
||||
# Teacher
|
||||
class Teacher(object):
|
||||
def __init__(self, name=None):
|
||||
self.name = name
|
||||
self.course = Course()
|
||||
|
||||
def provide_homework(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def provide_exam(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class MathTeacher(Teacher):
|
||||
def provide_homework(self):
|
||||
self.course.homework = 'This is Math homework provided by {}.'.format(self.name)
|
||||
|
||||
def provide_exam(self):
|
||||
self.course.exam = 'This is Math exam tested by {}.'.format(self.name)
|
||||
|
||||
|
||||
class HistoryTeacher(Teacher):
|
||||
def provide_homework(self):
|
||||
self.course.homework = 'This is History homework provided by {}.'.format(self.name)
|
||||
|
||||
def provide_exam(self):
|
||||
self.course.exam = 'This is History exam tested by {}.'.format(self.name)
|
||||
|
||||
|
||||
# Target objects to be produced
|
||||
class Course(object):
|
||||
def __init__(self):
|
||||
self.homework = None
|
||||
self.exam = None
|
||||
|
||||
def __str__(self):
|
||||
return 'Homework: {}\nExam: {}\n'.format(self.homework, self.exam)
|
||||
|
||||
|
||||
math_course = CourseBuilder(MathTeacher('Harry')).build_course()
|
||||
print(math_course)
|
||||
>>> Homework: This is Math homework provided by Harry.
|
||||
>>> Exam: This is Math exam tested by Harry.
|
||||
|
||||
history_course = CourseBuilder(HistoryTeacher('Potter')).build_course()
|
||||
print(history_course)
|
||||
>>> Homework: This is History homework provided by Potter.
|
||||
>>> Exam: This is History exam tested by Potter.
|
||||
```
|
@ -8,32 +8,33 @@ localeTitle: مزخرف
|
||||
|
||||
هنا مثال على تنفيذ Decorator في Python3.
|
||||
|
||||
`class MyText(object):
|
||||
def __init__(self, text=''):
|
||||
self.text = text
|
||||
|
||||
def __str__(self):
|
||||
return 'This is {}'.format(self.text)
|
||||
|
||||
|
||||
class BracketDecorator(object):
|
||||
def __init__(self, decoratee):
|
||||
self._decoratee = decoratee
|
||||
|
||||
def __str__(self):
|
||||
return '({})'.format(self._decoratee)
|
||||
|
||||
|
||||
class QuoteDecorator(object):
|
||||
def __init__(self, decoratee):
|
||||
self._decoratee = decoratee
|
||||
|
||||
def __str__(self):
|
||||
return '\"{}\"'.format(self._decoratee)
|
||||
|
||||
|
||||
print(BracketDecorator(MyText('apple')))
|
||||
>>> (This is apple)
|
||||
print(QuoteDecorator(MyText('banana')))
|
||||
>>> "This is banana"
|
||||
`
|
||||
```python
|
||||
class MyText(object):
|
||||
def __init__(self, text=''):
|
||||
self.text = text
|
||||
|
||||
def __str__(self):
|
||||
return 'This is {}'.format(self.text)
|
||||
|
||||
|
||||
class BracketDecorator(object):
|
||||
def __init__(self, decoratee):
|
||||
self._decoratee = decoratee
|
||||
|
||||
def __str__(self):
|
||||
return '({})'.format(self._decoratee)
|
||||
|
||||
|
||||
class QuoteDecorator(object):
|
||||
def __init__(self, decoratee):
|
||||
self._decoratee = decoratee
|
||||
|
||||
def __str__(self):
|
||||
return '\"{}\"'.format(self._decoratee)
|
||||
|
||||
|
||||
print(BracketDecorator(MyText('apple')))
|
||||
>>> (This is apple)
|
||||
print(QuoteDecorator(MyText('banana')))
|
||||
>>> "This is banana"
|
||||
```
|
@ -13,8 +13,9 @@ localeTitle: مصنع
|
||||
\`\` \`
|
||||
الواجهة العامة Animal { الفراغ الحديث () ؛ }
|
||||
|
||||
`We now need to have "concrete classes" - classes which implement our interface and define the associated functions/ variables.
|
||||
`
|
||||
```
|
||||
We now need to have "concrete classes" - classes which implement our interface and define the associated functions/ variables.
|
||||
```
|
||||
|
||||
`public class Dog implements Animal {
|
||||
|
||||
@ -34,8 +35,9 @@ localeTitle: مصنع
|
||||
}
|
||||
`
|
||||
|
||||
`We now define our "AnimalFactory" - the class which will handle the creation of these classes.
|
||||
`
|
||||
```
|
||||
We now define our "AnimalFactory" - the class which will handle the creation of these classes.
|
||||
```
|
||||
|
||||
`public class AnimalFactory {
|
||||
|
||||
@ -59,12 +61,13 @@ localeTitle: مصنع
|
||||
cat.talk();
|
||||
`
|
||||
|
||||
`Here we can see that the class with this instance of "Cat" doesn't really know which animal it has. But this doesn't matter - because all the classes the factory creates are concrete classes of the same interface, the parent class doesn't need to know the exact class it is using.
|
||||
|
||||
|
||||
## Factory in Python3
|
||||
We can implement a Factory easily with static methods.
|
||||
`
|
||||
```
|
||||
Here we can see that the class with this instance of "Cat" doesn't really know which animal it has. But this doesn't matter - because all the classes the factory creates are concrete classes of the same interface, the parent class doesn't need to know the exact class it is using.
|
||||
|
||||
|
||||
## Factory in Python3
|
||||
We can implement a Factory easily with static methods.
|
||||
```
|
||||
|
||||
الثعبان فئة الشراب (الكائن): def **init** (self، name، price = None): self.name = الاسم self.price = السعر
|
||||
|
||||
|
@ -92,32 +92,34 @@ Singleton هو نمط تصميم غالبًا ما يستخدم في Android. ي
|
||||
|
||||
يمكننا استخدام metaclass لتطبيق Singleton في Python3.
|
||||
|
||||
`class Singleton(type):
|
||||
# Mapping from a class to its singleton instance
|
||||
_instances = {}
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in Singleton._instances:
|
||||
Singleton._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
||||
|
||||
return Singleton._instances[cls]
|
||||
|
||||
|
||||
class MyClass(metaclass=Singleton):
|
||||
pass
|
||||
`
|
||||
```python
|
||||
class Singleton(type):
|
||||
# Mapping from a class to its singleton instance
|
||||
_instances = {}
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in Singleton._instances:
|
||||
Singleton._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
||||
|
||||
return Singleton._instances[cls]
|
||||
|
||||
|
||||
class MyClass(metaclass=Singleton):
|
||||
pass
|
||||
```
|
||||
|
||||
### اختبارات
|
||||
|
||||
`obj_0 = MyClass()
|
||||
obj_1 = MyClass()
|
||||
|
||||
In [2]: obj_0
|
||||
Out[2]: <__main__.MyClass at 0x111130da0>
|
||||
|
||||
In [3]: obj_1
|
||||
Out[3]: <__main__.MyClass at 0x111130da0>
|
||||
`
|
||||
```python
|
||||
obj_0 = MyClass()
|
||||
obj_1 = MyClass()
|
||||
|
||||
In [2]: obj_0
|
||||
Out[2]: <__main__.MyClass at 0x111130da0>
|
||||
|
||||
In [3]: obj_1
|
||||
Out[3]: <__main__.MyClass at 0x111130da0>
|
||||
```
|
||||
|
||||
## سينجلتون في دائرة الرقابة الداخلية
|
||||
|
||||
|
@ -30,10 +30,11 @@ localeTitle: برمجة وظيفية
|
||||
|
||||
في ما يلي مثال على `map` :
|
||||
|
||||
`const myList = [6, 3, 5, 29];
|
||||
|
||||
let squares = myList.map(num => num * num); // [36, 9, 25, 841]
|
||||
`
|
||||
```javascript
|
||||
const myList = [6, 3, 5, 29];
|
||||
|
||||
let squares = myList.map(num => num * num); // [36, 9, 25, 841]
|
||||
```
|
||||
|
||||
### معلومات اكثر:
|
||||
|
||||
|
@ -20,21 +20,23 @@ localeTitle: اختبارات الوحدة
|
||||
|
||||
افترض أن هناك وظيفة مكتوبة في ملف **add.js**
|
||||
|
||||
`var add = function(number1, number2){
|
||||
return number1 + number2;
|
||||
}
|
||||
`
|
||||
```javascript
|
||||
var add = function(number1, number2){
|
||||
return number1 + number2;
|
||||
}
|
||||
```
|
||||
|
||||
الآن ، من أجل كتابة اختبار الوحدة لهذه الوظيفة تحديدًا ، يمكننا استخدام أدوات الاختبار مثل [mocha](http://mochajs.org/)
|
||||
|
||||
`const mocha = require('mocha')
|
||||
const chai = require('chai') // It is an assertion library
|
||||
describe('Test to check add function', function(){
|
||||
it('should add two numbers', function(){
|
||||
(add(2,3)).should.equal(5) //Checking that 2+3 should equal 5 using the given add function
|
||||
});
|
||||
});
|
||||
`
|
||||
```javascript
|
||||
const mocha = require('mocha')
|
||||
const chai = require('chai') // It is an assertion library
|
||||
describe('Test to check add function', function(){
|
||||
it('should add two numbers', function(){
|
||||
(add(2,3)).should.equal(5) //Checking that 2+3 should equal 5 using the given add function
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### التطوير المدفوع بالاختبارات
|
||||
|
||||
|
@ -8,46 +8,50 @@ localeTitle: الأسماء المستعارة SQL
|
||||
|
||||
يمكنك استخدام AS لتعيين اسم لعمود البيانات الذي تقوم بتحديده أو الذي تم حسابه.
|
||||
|
||||
`SELECT user_only_num1 AS AgeOfServer, (user_only_num1 - warranty_period) AS NonWarrantyPeriod FROM server_table
|
||||
`
|
||||
```sql
|
||||
SELECT user_only_num1 AS AgeOfServer, (user_only_num1 - warranty_period) AS NonWarrantyPeriod FROM server_table
|
||||
```
|
||||
|
||||
هذه النتائج في الإخراج على النحو التالي.
|
||||
|
||||
`+-------------+------------------------+
|
||||
| AgeOfServer | NonWarrantyPeriod |
|
||||
+-------------+------------------------+
|
||||
| 36 | 24 |
|
||||
| 24 | 12 |
|
||||
| 61 | 49 |
|
||||
| 12 | 0 |
|
||||
| 6 | -6 |
|
||||
| 0 | -12 |
|
||||
| 36 | 24 |
|
||||
| 36 | 24 |
|
||||
| 24 | 12 |
|
||||
+-------------+------------------------+
|
||||
`
|
||||
```text
|
||||
+-------------+------------------------+
|
||||
| AgeOfServer | NonWarrantyPeriod |
|
||||
+-------------+------------------------+
|
||||
| 36 | 24 |
|
||||
| 24 | 12 |
|
||||
| 61 | 49 |
|
||||
| 12 | 0 |
|
||||
| 6 | -6 |
|
||||
| 0 | -12 |
|
||||
| 36 | 24 |
|
||||
| 36 | 24 |
|
||||
| 24 | 12 |
|
||||
+-------------+------------------------+
|
||||
```
|
||||
|
||||
يمكنك أيضًا استخدام AS لتعيين اسم لجدول لتسهيل الرجوع إليه في الصلات.
|
||||
|
||||
`SELECT ord.product, ord.ord_number, ord.price, cust.cust_name, cust.cust_number FROM customer_table AS cust
|
||||
|
||||
JOIN order_table AS ord ON cust.cust_number = ord.cust_number
|
||||
`
|
||||
```sql
|
||||
SELECT ord.product, ord.ord_number, ord.price, cust.cust_name, cust.cust_number FROM customer_table AS cust
|
||||
|
||||
JOIN order_table AS ord ON cust.cust_number = ord.cust_number
|
||||
```
|
||||
|
||||
هذه النتائج في الإخراج على النحو التالي.
|
||||
|
||||
`+-------------+------------+-----------+-----------------+--------------+
|
||||
| product | ord_number | price | cust_name | cust_number |
|
||||
+-------------+------------+-----------+-----------------+--------------+
|
||||
| RAM | 12345 | 124 | John Smith | 20 |
|
||||
| CPU | 12346 | 212 | Mia X | 22 |
|
||||
| USB | 12347 | 49 | Elise Beth | 21 |
|
||||
| Cable | 12348 | 0 | Paul Fort | 19 |
|
||||
| Mouse | 12349 | 66 | Nats Back | 15 |
|
||||
| Laptop | 12350 | 612 | Mel S | 36 |
|
||||
| Keyboard| 12351 | 24 | George Z | 95 |
|
||||
| Keyboard| 12352 | 24 | Ally B | 55 |
|
||||
| Air | 12353 | 12 | Maria Trust | 11 |
|
||||
+-------------+------------+-----------+-----------------+--------------+
|
||||
`
|
||||
```text
|
||||
+-------------+------------+-----------+-----------------+--------------+
|
||||
| product | ord_number | price | cust_name | cust_number |
|
||||
+-------------+------------+-----------+-----------------+--------------+
|
||||
| RAM | 12345 | 124 | John Smith | 20 |
|
||||
| CPU | 12346 | 212 | Mia X | 22 |
|
||||
| USB | 12347 | 49 | Elise Beth | 21 |
|
||||
| Cable | 12348 | 0 | Paul Fort | 19 |
|
||||
| Mouse | 12349 | 66 | Nats Back | 15 |
|
||||
| Laptop | 12350 | 612 | Mel S | 36 |
|
||||
| Keyboard| 12351 | 24 | George Z | 95 |
|
||||
| Keyboard| 12352 | 24 | Ally B | 55 |
|
||||
| Air | 12353 | 12 | Maria Trust | 11 |
|
||||
+-------------+------------+-----------+-----------------+--------------+
|
||||
```
|
@ -10,25 +10,28 @@ localeTitle: مزود والمشغل
|
||||
|
||||
في ما يلي جدول الطالب بدون شرط WHERE:
|
||||
|
||||
`select * from student;
|
||||
`
|
||||
```sql
|
||||
select * from student;
|
||||
```
|
||||
|
||||

|
||||
|
||||
الآن تتم إضافة عبارة WHERE لعرض طلاب البرمجة فقط:
|
||||
|
||||
`select * from student
|
||||
where programOfStudy = 'Programming';
|
||||
`
|
||||
```sql
|
||||
select * from student
|
||||
where programOfStudy = 'Programming';
|
||||
```
|
||||
|
||||

|
||||
|
||||
الآن يتم تحديث جملة WHERE بـ AND لعرض نتائج لطلاب البرمجة التي يكون لها أيضًا درجة SAT أكبر من 800:
|
||||
|
||||
`select * from student
|
||||
where programOfStudy = 'Programming'
|
||||
and sat_score > 800;
|
||||
`
|
||||
```sql
|
||||
select * from student
|
||||
where programOfStudy = 'Programming'
|
||||
and sat_score > 800;
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
@ -8,16 +8,18 @@ localeTitle: دالة Avg SQL
|
||||
|
||||
هنا هو بناء الجملة لاستخدام الوظيفة:
|
||||
|
||||
`select groupingField, avg(num_field)
|
||||
from table1
|
||||
group by groupingField
|
||||
`
|
||||
```sql
|
||||
select groupingField, avg(num_field)
|
||||
from table1
|
||||
group by groupingField
|
||||
```
|
||||
|
||||
إليك مثال على ذلك باستخدام جدول الطالب:
|
||||
|
||||
`select studentID, FullName, avg(sat_score)
|
||||
from student
|
||||
group by studentID, FullName;
|
||||
`
|
||||
```sql
|
||||
select studentID, FullName, avg(sat_score)
|
||||
from student
|
||||
group by studentID, FullName;
|
||||
```
|
||||
|
||||

|
@ -14,10 +14,11 @@ localeTitle: مزود بين المشغل
|
||||
|
||||
هنا هو بناء الجملة لاستخدام الدالة في جملة WHERE:
|
||||
|
||||
`select field1, testField
|
||||
from table1
|
||||
where testField between min and max
|
||||
`
|
||||
```sql
|
||||
select field1, testField
|
||||
from table1
|
||||
where testField between min and max
|
||||
```
|
||||
|
||||
في ما يلي مثال على استخدام جدول الطالب وعبارة WHERE:
|
||||
|
||||
@ -35,12 +36,13 @@ localeTitle: مزود بين المشغل
|
||||
|
||||
في ما يلي مثال على ذلك باستخدام جدول أموال الحملة والعبارة الفرعية. سيؤدي هذا إلى إرجاع صفوف يتراوح فيها مجموع التبرعات للمرشح بين 3 ملايين و 18 مليون دولار استنادًا إلى شرط HAVING في الجزء GROUP BY من البيان. المزيد عن التجميع في هذا الدليل.
|
||||
|
||||
`select Candidate, Office_Sought, Election_Year, format(sum(Total_$),2)
|
||||
from combined_party_data
|
||||
where Election_Year = 2016
|
||||
group by Candidate, Office_Sought, Election_Year
|
||||
having sum(Total_$) between 3000000 and 18000000
|
||||
order by sum(Total_$) desc;
|
||||
`
|
||||
```sql
|
||||
select Candidate, Office_Sought, Election_Year, format(sum(Total_$),2)
|
||||
from combined_party_data
|
||||
where Election_Year = 2016
|
||||
group by Candidate, Office_Sought, Election_Year
|
||||
having sum(Total_$) between 3000000 and 18000000
|
||||
order by sum(Total_$) desc;
|
||||
```
|
||||
|
||||

|
@ -14,38 +14,41 @@ localeTitle: SQL CHECK القيد
|
||||
|
||||
**الخلية:**
|
||||
|
||||
`CREATE TABLE Persons (
|
||||
ID int NOT NULL,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Age int,
|
||||
CHECK (Age>=18)
|
||||
);
|
||||
`
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
ID int NOT NULL,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Age int,
|
||||
CHECK (Age>=18)
|
||||
);
|
||||
```
|
||||
|
||||
**SQL Server / Oracle / MS Access:**
|
||||
|
||||
`CREATE TABLE Persons (
|
||||
ID int NOT NULL,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Age int CHECK (Age>=18)
|
||||
);
|
||||
`
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
ID int NOT NULL,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Age int CHECK (Age>=18)
|
||||
);
|
||||
```
|
||||
|
||||
للسماح بتسمية قيد CHECK ، ولتحديد قيد CHECK على أعمدة متعددة ، استخدم بناء جملة SQL التالي:
|
||||
|
||||
**MySQL / SQL Server / Oracle / MS Access:**
|
||||
|
||||
`CREATE TABLE Persons (
|
||||
ID int NOT NULL,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Age int,
|
||||
City varchar(255),
|
||||
CONSTRAINT CHK_Person CHECK (Age>=18 AND City='Sandnes')
|
||||
);
|
||||
`
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
ID int NOT NULL,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Age int,
|
||||
City varchar(255),
|
||||
CONSTRAINT CHK_Person CHECK (Age>=18 AND City='Sandnes')
|
||||
);
|
||||
```
|
||||
|
||||
### SQL الاختيار على ALTER TABLE
|
||||
|
||||
@ -53,17 +56,19 @@ localeTitle: SQL CHECK القيد
|
||||
|
||||
**MySQL / SQL Server / Oracle / MS Access:**
|
||||
|
||||
`ALTER TABLE Persons
|
||||
ADD CHECK (Age>=18);
|
||||
`
|
||||
```sql
|
||||
ALTER TABLE Persons
|
||||
ADD CHECK (Age>=18);
|
||||
```
|
||||
|
||||
للسماح بتسمية قيد CHECK ، ولتحديد قيد CHECK على أعمدة متعددة ، استخدم بناء جملة SQL التالي:
|
||||
|
||||
**MySQL / SQL Server / Oracle / MS Access:**
|
||||
|
||||
`ALTER TABLE Persons
|
||||
ADD CONSTRAINT CHK_PersonAge CHECK (Age>=18 AND City='Sandnes');
|
||||
`
|
||||
```sql
|
||||
ALTER TABLE Persons
|
||||
ADD CONSTRAINT CHK_PersonAge CHECK (Age>=18 AND City='Sandnes');
|
||||
```
|
||||
|
||||
### انخفاض القيد الاختيار
|
||||
|
||||
@ -71,12 +76,14 @@ localeTitle: SQL CHECK القيد
|
||||
|
||||
**SQL Server / Oracle / MS Access:**
|
||||
|
||||
`ALTER TABLE Persons
|
||||
DROP CONSTRAINT CHK_PersonAge;
|
||||
`
|
||||
```sql
|
||||
ALTER TABLE Persons
|
||||
DROP CONSTRAINT CHK_PersonAge;
|
||||
```
|
||||
|
||||
**الخلية:**
|
||||
|
||||
`ALTER TABLE Persons
|
||||
DROP CHECK CHK_PersonAge;
|
||||
`
|
||||
```sql
|
||||
ALTER TABLE Persons
|
||||
DROP CHECK CHK_PersonAge;
|
||||
```
|
@ -15,15 +15,17 @@ localeTitle: COUNT COUNT Aggregate Function
|
||||
|
||||
كمرجع ، إليك البيانات الحالية لجميع الصفوف في قاعدة بيانات الطلاب الخاصة بنا.
|
||||
|
||||
`select studentID, FullName, programOfStudy, sat_score from student; -- all records with fields of interest
|
||||
`
|
||||
```sql
|
||||
select studentID, FullName, programOfStudy, sat_score from student; -- all records with fields of interest
|
||||
```
|
||||
|
||||

|
||||
|
||||
توفر عبارة SQL هذه حسابًا لكل الصفوف. لاحظ أنه يمكنك منح عمود COUNT الناتج اسمًا باستخدام "AS".
|
||||
|
||||
`select count(*) AS studentCount from student; -- count of all records
|
||||
`
|
||||
```sql
|
||||
select count(*) AS studentCount from student; -- count of all records
|
||||
```
|
||||
|
||||

|
||||
|
||||
@ -43,11 +45,12 @@ localeTitle: COUNT COUNT Aggregate Function
|
||||
|
||||
في ما يلي مثال على ذلك باستخدام جدول أموال الحملة. هذا هو مجموع الدولارات في كل معاملة وعدد المساهمات لكل حزب سياسي خلال الحملة الرئاسية الأمريكية لعام 2016.
|
||||
|
||||
`select Specific_Party, Election_Year, format(sum(Total_$),2) AS contribution$Total, count(*) AS numberOfContributions
|
||||
from combined_party_data
|
||||
group by Specific_Party,Election_Year
|
||||
having Election_Year = 2016;
|
||||
`
|
||||
```sql
|
||||
select Specific_Party, Election_Year, format(sum(Total_$),2) AS contribution$Total, count(*) AS numberOfContributions
|
||||
from combined_party_data
|
||||
group by Specific_Party,Election_Year
|
||||
having Election_Year = 2016;
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
@ -15,9 +15,10 @@ localeTitle: SQL CREATE INDEX Statement
|
||||
|
||||
فيما يلي مثال على صيغة بناء بيان الفهرس. لاحظ أن بناء الجملة يسمح لفهرس أن يكون أكثر من عمود واحد.
|
||||
|
||||
`CREATE INDEX index_name
|
||||
ON table_name (column1, column2, ...);
|
||||
`
|
||||
```sql
|
||||
CREATE INDEX index_name
|
||||
ON table_name (column1, column2, ...);
|
||||
```
|
||||
|
||||
إنشاء فهرس جديد في حقل جدول الطالب ، programOfStudy. كمرجع ، إليك التعريف الحالي لجدول الطالب.
|
||||
|
||||
@ -25,9 +26,10 @@ localeTitle: SQL CREATE INDEX Statement
|
||||
|
||||
إليك بيان لإنشاء الفهرس ، ولقطة شاشة لتعريف الجدول المحدّث:
|
||||
|
||||
`create index pStudyIndex
|
||||
on student (programOfStudy);
|
||||
`
|
||||
```sql
|
||||
create index pStudyIndex
|
||||
on student (programOfStudy);
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
@ -12,17 +12,19 @@ localeTitle: SQL CREATE INDEX Statement
|
||||
|
||||
ينشئ فهرس على جدول. القيم المكررة مسموح بها:
|
||||
|
||||
`CREATE INDEX index_name
|
||||
ON table_name (column1, column2, ...);
|
||||
`
|
||||
```sql
|
||||
CREATE INDEX index_name
|
||||
ON table_name (column1, column2, ...);
|
||||
```
|
||||
|
||||
#### خلق فريدة من نوعها INDEX البناء
|
||||
|
||||
ينشئ فهرس فريد على جدول. القيم المكررة غير مسموح بها:
|
||||
|
||||
`CREATE UNIQUE INDEX index_name
|
||||
ON table_name (column1, column2, ...);
|
||||
`
|
||||
```sql
|
||||
CREATE UNIQUE INDEX index_name
|
||||
ON table_name (column1, column2, ...);
|
||||
```
|
||||
|
||||
> **ملاحظة:** يختلف بناء جملة إنشاء الفهارس بين قواعد بيانات مختلفة. لذلك: تحقق من بناء الجملة لإنشاء فهارس في قاعدة البيانات الخاصة بك.
|
||||
|
||||
@ -30,14 +32,16 @@ localeTitle: SQL CREATE INDEX Statement
|
||||
|
||||
ينشئ عبارة SQL أدناه فهرس المسمى "idx\_lastname" على العمود "اسم العائلة" في جدول "الأشخاص":
|
||||
|
||||
`CREATE INDEX idx_lastname
|
||||
ON Persons (LastName);
|
||||
`
|
||||
```sql
|
||||
CREATE INDEX idx_lastname
|
||||
ON Persons (LastName);
|
||||
```
|
||||
|
||||
إذا كنت تريد إنشاء فهرس على مجموعة من الأعمدة ، فيمكنك سرد أسماء الأعمدة داخل الأقواس ، مفصولة بفواصل: CREATE INDEX idx\_pname
|
||||
|
||||
`ON Persons (LastName, FirstName);
|
||||
`
|
||||
```sql
|
||||
ON Persons (LastName, FirstName);
|
||||
```
|
||||
|
||||
#### DROP INDEX بيان
|
||||
|
||||
@ -45,21 +49,25 @@ localeTitle: SQL CREATE INDEX Statement
|
||||
|
||||
**MS Access:**
|
||||
|
||||
`DROP INDEX index_name ON table_name;
|
||||
`
|
||||
```sql
|
||||
DROP INDEX index_name ON table_name;
|
||||
```
|
||||
|
||||
**خادم قاعدة البيانات:**
|
||||
|
||||
`DROP INDEX table_name.index_name;
|
||||
`
|
||||
```sql
|
||||
DROP INDEX table_name.index_name;
|
||||
```
|
||||
|
||||
**DB2 / أوراكل:**
|
||||
|
||||
`DROP INDEX index_name;
|
||||
`
|
||||
```sql
|
||||
DROP INDEX index_name;
|
||||
```
|
||||
|
||||
**الخلية:**
|
||||
|
||||
`ALTER TABLE table_name
|
||||
DROP INDEX index_name;
|
||||
`
|
||||
```sql
|
||||
ALTER TABLE table_name
|
||||
DROP INDEX index_name;
|
||||
```
|
@ -8,19 +8,21 @@ localeTitle: SQL إنشاء بيان جدول
|
||||
|
||||
لإنشاء جدول في قاعدة بيانات تستخدم عبارة `CREATE TABLE` . يمكنك إعطاء اسم إلى الجدول وقائمة بالأعمدة مع أنواع البيانات الخاصة بها.
|
||||
|
||||
`CREATE TABLE TABLENAME(Attribute1 Datatype, Attribute2 Datatype,........);
|
||||
`
|
||||
```
|
||||
CREATE TABLE TABLENAME(Attribute1 Datatype, Attribute2 Datatype,........);
|
||||
```
|
||||
|
||||
في ما يلي مثال على إنشاء جدول باسم الشخص:
|
||||
|
||||
`CREATE TABLE Person(
|
||||
Id int not null,
|
||||
Name varchar not null,
|
||||
DateOfBirth date not null,
|
||||
Gender bit not null,
|
||||
PRIMARY KEY( Id )
|
||||
);
|
||||
`
|
||||
```sql
|
||||
CREATE TABLE Person(
|
||||
Id int not null,
|
||||
Name varchar not null,
|
||||
DateOfBirth date not null,
|
||||
Gender bit not null,
|
||||
PRIMARY KEY( Id )
|
||||
);
|
||||
```
|
||||
|
||||
في المثال أعلاه ، يكون لكل شخص اسم وتاريخ الميلاد وجنس. يعد عمود المعرّف هو المفتاح الذي يحدد شخصًا واحدًا في الجدول. يمكنك استخدام الكلمة الأساسية `PRIMARY KEY` لتكوين عمود واحد أو أكثر كمفتاح أساسي.
|
||||
|
||||
|
@ -33,8 +33,9 @@ localeTitle: SQL إنشاء جدول
|
||||
|
||||
سنقوم بإنشاء المخطط للتعلم والاختبار باستخدام الأمر SQL ؛
|
||||
|
||||
`create database fCC_alterTableGuide;
|
||||
`
|
||||
```
|
||||
create database fCC_alterTableGuide;
|
||||
```
|
||||
|
||||
هذه الأمثلة بنية المخطط قبل تشغيل هذا الأمر
|
||||
|
||||
|
@ -35,10 +35,11 @@ A View هو كائن قاعدة بيانات يقدم البيانات المو
|
||||
|
||||
_سيغطي هذا الدليل هذا الجزء من البيان ..._
|
||||
|
||||
`CREATE
|
||||
VIEW view_name [(column_list)]
|
||||
AS select_statement
|
||||
`
|
||||
```sql
|
||||
CREATE
|
||||
VIEW view_name [(column_list)]
|
||||
AS select_statement
|
||||
```
|
||||
|
||||
### إنشاء نموذج للعرض من جداول الطلاب
|
||||
|
||||
|
@ -18,14 +18,15 @@ localeTitle: دالات تاريخ SQL
|
||||
|
||||
الحصول على التاريخ من النظام يمكن أن يكون سهل جدا لمعالجة البيانات باستخدام SQL.
|
||||
|
||||
`-- current date
|
||||
select now(), sysdate(), current_date(), current_time(), -- date and time from the system on execution
|
||||
dayofyear(now()) as NumDaysSoFarThisYr,
|
||||
EXTRACT(YEAR FROM now()) as theYearPart,
|
||||
EXTRACT(YEAR_MONTH FROM now()) as theYrMonPart,
|
||||
date_format(now(), '%W %M %Y') as oneOfManyFormats;
|
||||
;
|
||||
`
|
||||
```sql
|
||||
-- current date
|
||||
select now(), sysdate(), current_date(), current_time(), -- date and time from the system on execution
|
||||
dayofyear(now()) as NumDaysSoFarThisYr,
|
||||
EXTRACT(YEAR FROM now()) as theYearPart,
|
||||
EXTRACT(YEAR_MONTH FROM now()) as theYrMonPart,
|
||||
date_format(now(), '%W %M %Y') as oneOfManyFormats;
|
||||
;
|
||||
```
|
||||
|
||||

|
||||
|
||||
@ -39,12 +40,13 @@ localeTitle: دالات تاريخ SQL
|
||||
|
||||
### تاريخ الرياضيات
|
||||
|
||||
`select now(), current_date(),
|
||||
datediff(now(),'2017-01-01') as daysThisYear,
|
||||
subdate(current_date(), interval 150 day) as '150DaysAgo',
|
||||
adddate(now(), interval 7 day) as dateInA_Week -- date in a week
|
||||
;
|
||||
`
|
||||
```sql
|
||||
select now(), current_date(),
|
||||
datediff(now(),'2017-01-01') as daysThisYear,
|
||||
subdate(current_date(), interval 150 day) as '150DaysAgo',
|
||||
adddate(now(), interval 7 day) as dateInA_Week -- date in a week
|
||||
;
|
||||
```
|
||||
|
||||

|
||||
|
||||
@ -58,10 +60,11 @@ localeTitle: دالات تاريخ SQL
|
||||
|
||||
فيما يلي مثالان على استخدام تاريخ الرياضيات في مكان جملة:
|
||||
|
||||
`select * from student; - to show the current data being used for the example
|
||||
select * from student where recordCreated < '2017-01-01';
|
||||
select * from student where recordCreated < subdate(current_date(), interval 225 day);
|
||||
`
|
||||
```sql
|
||||
select * from student; - to show the current data being used for the example
|
||||
select * from student where recordCreated < '2017-01-01';
|
||||
select * from student where recordCreated < subdate(current_date(), interval 225 day);
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
@ -8,23 +8,27 @@ localeTitle: SQL حذف بيان
|
||||
|
||||
كن حذرا. يمكنك حذف جميع سجلات الجدول أو مجرد عدد قليل. استخدم شرط `WHERE` لتحديد السجلات التي تريد حذفها. الصيغة هي:
|
||||
|
||||
`DELETE FROM table_name
|
||||
WHERE condition;
|
||||
`
|
||||
```sql
|
||||
DELETE FROM table_name
|
||||
WHERE condition;
|
||||
```
|
||||
|
||||
إليك مثال على الحذف من الجدول Person the record with Id 3:
|
||||
|
||||
`DELETE FROM Person
|
||||
WHERE Id = 3;
|
||||
`
|
||||
```sql
|
||||
DELETE FROM Person
|
||||
WHERE Id = 3;
|
||||
```
|
||||
|
||||
باستخدام DELETE لإزالة كافة السجلات من جدول محدد
|
||||
|
||||
`DELETE * FROM Person
|
||||
;
|
||||
`
|
||||
```sql
|
||||
DELETE * FROM Person
|
||||
;
|
||||
```
|
||||
|
||||
أو اعتمادًا على RDBMS الخاص بك ، يمكنك استخدام عبارة TRUNCATE TABLE التي تقوم بحذف كافة السجلات من جدول ، كما قد تسمح أو لا تسمح بالتراجع طبقًا لـ RDBMS الخاص بك. DELETE هو DML و TRUNCATE هو DDL.
|
||||
|
||||
`TRUNCATE TABLE Person;
|
||||
`
|
||||
```sql
|
||||
TRUNCATE TABLE Person;
|
||||
```
|
@ -23,16 +23,18 @@ A View هو كائن يقدم البيانات من جدول واحد أو أك
|
||||
|
||||
### بناء الجملة الأساسي
|
||||
|
||||
`DROP VIEW [IF EXISTS]
|
||||
view_name [, view_name] ...
|
||||
`
|
||||
```sql
|
||||
DROP VIEW [IF EXISTS]
|
||||
view_name [, view_name] ...
|
||||
```
|
||||
|
||||
### إسقاط عرض SQL
|
||||
|
||||
الجزء الموجود في حالة وجود أخطاء "اعتراض" ، في حالة عدم وجود طريقة العرض.
|
||||
|
||||
`drop view if exists students_dropMe_v;
|
||||
`
|
||||
```sql
|
||||
drop view if exists students_dropMe_v;
|
||||
```
|
||||
|
||||
طريقة العرض بعد الإنشاء:
|
||||
|
||||
|
@ -18,16 +18,18 @@ localeTitle: SQL الخارجية مفتاح القيد
|
||||
|
||||
لاحظ أن جدول الطالب يحتوي على مفتاح أساسي عمود واحد للطالب.
|
||||
|
||||
`SHOW index FROM student;
|
||||
`
|
||||
```sql
|
||||
SHOW index FROM student;
|
||||
```
|
||||
|
||||
`+---------+------------+----------+--------------+-------------+
|
||||
| Table | Non_unique | Key_name | Seq_in_index | Column_name |
|
||||
+---------+------------+----------+--------------+-------------+
|
||||
| student | 0 | PRIMARY | 1 | studentID |
|
||||
+---------+------------+----------+--------------+-------------+
|
||||
1 row in set (0.00 sec) (some columns removed on the right for clarity)
|
||||
`
|
||||
```text
|
||||
+---------+------------+----------+--------------+-------------+
|
||||
| Table | Non_unique | Key_name | Seq_in_index | Column_name |
|
||||
+---------+------------+----------+--------------+-------------+
|
||||
| student | 0 | PRIMARY | 1 | studentID |
|
||||
+---------+------------+----------+--------------+-------------+
|
||||
1 row in set (0.00 sec) (some columns removed on the right for clarity)
|
||||
```
|
||||
|
||||
### مفاتيح الجدول الأساسي والأجنبي للطفل
|
||||
|
||||
@ -36,29 +38,32 @@ localeTitle: SQL الخارجية مفتاح القيد
|
||||
``SHOW index FROM `student-contact-info`;
|
||||
``
|
||||
|
||||
`+----------------------+------------+----------+--------------+-------------+
|
||||
| Table | Non_unique | Key_name | Seq_in_index | Column_name |
|
||||
+----------------------+------------+----------+--------------+-------------+
|
||||
| student-contact-info | 0 | PRIMARY | 1 | studentID |
|
||||
+----------------------+------------+----------+--------------+-------------+
|
||||
1 row in set (0.00 sec) (some columns removed on the right for clarity)
|
||||
`
|
||||
```text
|
||||
+----------------------+------------+----------+--------------+-------------+
|
||||
| Table | Non_unique | Key_name | Seq_in_index | Column_name |
|
||||
+----------------------+------------+----------+--------------+-------------+
|
||||
| student-contact-info | 0 | PRIMARY | 1 | studentID |
|
||||
+----------------------+------------+----------+--------------+-------------+
|
||||
1 row in set (0.00 sec) (some columns removed on the right for clarity)
|
||||
```
|
||||
|
||||
`SELECT concat(table_name, '.', column_name) AS 'foreign key',
|
||||
concat(referenced_table_name, '.', referenced_column_name) AS 'references'
|
||||
FROM information_schema.key_column_usage
|
||||
WHERE referenced_table_name IS NOT NULL
|
||||
AND table_schema = 'fcc_sql_guides_database'
|
||||
AND table_name = 'student-contact-info';
|
||||
`
|
||||
```sql
|
||||
SELECT concat(table_name, '.', column_name) AS 'foreign key',
|
||||
concat(referenced_table_name, '.', referenced_column_name) AS 'references'
|
||||
FROM information_schema.key_column_usage
|
||||
WHERE referenced_table_name IS NOT NULL
|
||||
AND table_schema = 'fcc_sql_guides_database'
|
||||
AND table_name = 'student-contact-info';
|
||||
```
|
||||
|
||||
`+--------------------------------+-------------------+
|
||||
| foreign key | references |
|
||||
+--------------------------------+-------------------+
|
||||
| student-contact-info.studentID | student.studentID |
|
||||
+--------------------------------+-------------------+
|
||||
1 row in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+--------------------------------+-------------------+
|
||||
| foreign key | references |
|
||||
+--------------------------------+-------------------+
|
||||
| student-contact-info.studentID | student.studentID |
|
||||
+--------------------------------+-------------------+
|
||||
1 row in set (0.00 sec)
|
||||
```
|
||||
|
||||
### مثال على التقرير باستخدام جدول الطالب الرئيسي والجدول الفرعي للاتصال
|
||||
|
||||
@ -68,19 +73,20 @@ localeTitle: SQL الخارجية مفتاح القيد
|
||||
JOIN `student-contact-info` AS b ON a.studentID = b.studentID;
|
||||
``
|
||||
|
||||
`+-----------+------------------------+------------------+--------------------+--------------------+
|
||||
| studentID | FullName | programOfStudy | student-phone-cell | student-US-zipcode |
|
||||
+-----------+------------------------+------------------+--------------------+--------------------+
|
||||
| 1 | Monique Davis | Literature | 555-555-5551 | 97111 |
|
||||
| 2 | Teri Gutierrez | Programming | 555-555-5552 | 97112 |
|
||||
| 3 | Spencer Pautier | Programming | 555-555-5553 | 97113 |
|
||||
| 4 | Louis Ramsey | Programming | 555-555-5554 | 97114 |
|
||||
| 5 | Alvin Greene | Programming | 555-555-5555 | 97115 |
|
||||
| 6 | Sophie Freeman | Programming | 555-555-5556 | 97116 |
|
||||
| 7 | Edgar Frank "Ted" Codd | Computer Science | 555-555-5557 | 97117 |
|
||||
| 8 | Donald D. Chamberlin | Computer Science | 555-555-5558 | 97118 |
|
||||
+-----------+------------------------+------------------+--------------------+--------------------+
|
||||
`
|
||||
```text
|
||||
+-----------+------------------------+------------------+--------------------+--------------------+
|
||||
| studentID | FullName | programOfStudy | student-phone-cell | student-US-zipcode |
|
||||
+-----------+------------------------+------------------+--------------------+--------------------+
|
||||
| 1 | Monique Davis | Literature | 555-555-5551 | 97111 |
|
||||
| 2 | Teri Gutierrez | Programming | 555-555-5552 | 97112 |
|
||||
| 3 | Spencer Pautier | Programming | 555-555-5553 | 97113 |
|
||||
| 4 | Louis Ramsey | Programming | 555-555-5554 | 97114 |
|
||||
| 5 | Alvin Greene | Programming | 555-555-5555 | 97115 |
|
||||
| 6 | Sophie Freeman | Programming | 555-555-5556 | 97116 |
|
||||
| 7 | Edgar Frank "Ted" Codd | Computer Science | 555-555-5557 | 97117 |
|
||||
| 8 | Donald D. Chamberlin | Computer Science | 555-555-5558 | 97118 |
|
||||
+-----------+------------------------+------------------+--------------------+--------------------+
|
||||
```
|
||||
|
||||
### استنتاج
|
||||
|
||||
|
@ -14,27 +14,29 @@ localeTitle: مجموعة SQL بيان
|
||||
|
||||
إن ترتيب مجموعة البيانات هذه في ترتيب تنازلي (DESC) يضع المرشحين الذين لديهم أكبر مساهمات إجمالية في أعلى القائمة.
|
||||
|
||||
`SELECT Candidate, Election_year, sum(Total_$), count(*)
|
||||
FROM combined_party_data
|
||||
WHERE Election_year = 2016
|
||||
GROUP BY Candidate, Election_year -- this tells the DBMS to summarize by these two columns
|
||||
HAVING sum(Total_$) > 20000000 -- limits the rows presented from the summary of money ($20 Million USD)
|
||||
ORDER BY sum(Total_$) DESC; -- orders the presented rows with the largest ones first.
|
||||
`
|
||||
```sql
|
||||
SELECT Candidate, Election_year, sum(Total_$), count(*)
|
||||
FROM combined_party_data
|
||||
WHERE Election_year = 2016
|
||||
GROUP BY Candidate, Election_year -- this tells the DBMS to summarize by these two columns
|
||||
HAVING sum(Total_$) > 20000000 -- limits the rows presented from the summary of money ($20 Million USD)
|
||||
ORDER BY sum(Total_$) DESC; -- orders the presented rows with the largest ones first.
|
||||
```
|
||||
|
||||
`+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| Candidate | Election_year | sum(Total_$) | count(*) |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| CLINTON, HILLARY RODHAM & KAINE, TIMOTHY M (TIM) | 2016 | 568135094.4400003 | 126 |
|
||||
| TRUMP, DONALD J & PENCE, MICHAEL R (MIKE) | 2016 | 366853142.7899999 | 114 |
|
||||
| SANDERS, BERNARD (BERNIE) | 2016 | 258562022.17 | 122 |
|
||||
| CRUZ, RAFAEL EDWARD (TED) | 2016 | 93430700.29000005 | 104 |
|
||||
| CARSON, BENJAMIN S (BEN) | 2016 | 62202411.12999996 | 93 |
|
||||
| RUBIO, MARCO ANTONIO | 2016 | 44384313.9 | 106 |
|
||||
| BUSH, JOHN ELLIS (JEB) | 2016 | 34606731.78 | 97 |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
7 rows in set (0.01 sec)
|
||||
`
|
||||
```text
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| Candidate | Election_year | sum(Total_$) | count(*) |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| CLINTON, HILLARY RODHAM & KAINE, TIMOTHY M (TIM) | 2016 | 568135094.4400003 | 126 |
|
||||
| TRUMP, DONALD J & PENCE, MICHAEL R (MIKE) | 2016 | 366853142.7899999 | 114 |
|
||||
| SANDERS, BERNARD (BERNIE) | 2016 | 258562022.17 | 122 |
|
||||
| CRUZ, RAFAEL EDWARD (TED) | 2016 | 93430700.29000005 | 104 |
|
||||
| CARSON, BENJAMIN S (BEN) | 2016 | 62202411.12999996 | 93 |
|
||||
| RUBIO, MARCO ANTONIO | 2016 | 44384313.9 | 106 |
|
||||
| BUSH, JOHN ELLIS (JEB) | 2016 | 34606731.78 | 97 |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
7 rows in set (0.01 sec)
|
||||
```
|
||||
|
||||
كما هو الحال مع كل هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي.
|
||||
|
||||
|
@ -16,27 +16,29 @@ localeTitle: SQL وجود جملة
|
||||
|
||||
إن ترتيب مجموعة البيانات هذه في ترتيب تنازلي (DESC) يضع المرشحين الذين لديهم أكبر مساهمات إجمالية في أعلى القائمة.
|
||||
|
||||
`SELECT Candidate, Election_year, sum(Total_$), count(*)
|
||||
FROM combined_party_data
|
||||
WHERE Election_year = 2016
|
||||
GROUP BY Candidate, Election_year -- this tells the DBMS to summarize by these two columns
|
||||
HAVING sum(Total_$) > 20000000 -- limits the rows presented from the summary of money ($20 Million USD)
|
||||
ORDER BY sum(Total_$) DESC; -- orders the presented rows with the largest ones first.
|
||||
`
|
||||
```sql
|
||||
SELECT Candidate, Election_year, sum(Total_$), count(*)
|
||||
FROM combined_party_data
|
||||
WHERE Election_year = 2016
|
||||
GROUP BY Candidate, Election_year -- this tells the DBMS to summarize by these two columns
|
||||
HAVING sum(Total_$) > 20000000 -- limits the rows presented from the summary of money ($20 Million USD)
|
||||
ORDER BY sum(Total_$) DESC; -- orders the presented rows with the largest ones first.
|
||||
```
|
||||
|
||||
`+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| Candidate | Election_year | sum(Total_$) | count(*) |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| CLINTON, HILLARY RODHAM & KAINE, TIMOTHY M (TIM) | 2016 | 568135094.4400003 | 126 |
|
||||
| TRUMP, DONALD J & PENCE, MICHAEL R (MIKE) | 2016 | 366853142.7899999 | 114 |
|
||||
| SANDERS, BERNARD (BERNIE) | 2016 | 258562022.17 | 122 |
|
||||
| CRUZ, RAFAEL EDWARD (TED) | 2016 | 93430700.29000005 | 104 |
|
||||
| CARSON, BENJAMIN S (BEN) | 2016 | 62202411.12999996 | 93 |
|
||||
| RUBIO, MARCO ANTONIO | 2016 | 44384313.9 | 106 |
|
||||
| BUSH, JOHN ELLIS (JEB) | 2016 | 34606731.78 | 97 |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
7 rows in set (0.01 sec)
|
||||
`
|
||||
```text
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| Candidate | Election_year | sum(Total_$) | count(*) |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| CLINTON, HILLARY RODHAM & KAINE, TIMOTHY M (TIM) | 2016 | 568135094.4400003 | 126 |
|
||||
| TRUMP, DONALD J & PENCE, MICHAEL R (MIKE) | 2016 | 366853142.7899999 | 114 |
|
||||
| SANDERS, BERNARD (BERNIE) | 2016 | 258562022.17 | 122 |
|
||||
| CRUZ, RAFAEL EDWARD (TED) | 2016 | 93430700.29000005 | 104 |
|
||||
| CARSON, BENJAMIN S (BEN) | 2016 | 62202411.12999996 | 93 |
|
||||
| RUBIO, MARCO ANTONIO | 2016 | 44384313.9 | 106 |
|
||||
| BUSH, JOHN ELLIS (JEB) | 2016 | 34606731.78 | 97 |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
7 rows in set (0.01 sec)
|
||||
```
|
||||
|
||||
كما هو الحال مع كل هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي.
|
||||
|
||||
|
@ -10,39 +10,43 @@ localeTitle: مزود في المشغل
|
||||
|
||||
في ما يلي قائمة الطلاب الكاملة الحالية لمقارنة مجموعة نتائج `WHERE` :
|
||||
|
||||
`select studentID, FullName, sat_score, rcd_updated from student;
|
||||
`
|
||||
```sql
|
||||
select studentID, FullName, sat_score, rcd_updated from student;
|
||||
```
|
||||
|
||||
`+-----------+------------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
سيتم عرض الصفوف التي لها نقاط SAT في هذه القائمة (1000 ، 2400):
|
||||
|
||||
`select studentID, FullName, sat_score, rcd_updated
|
||||
from student
|
||||
where sat_score in (1000, 2400);
|
||||
`
|
||||
```sql
|
||||
select studentID, FullName, sat_score, rcd_updated
|
||||
from student
|
||||
where sat_score in (1000, 2400);
|
||||
```
|
||||
|
||||
`+-----------+------------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| 3 | Spencer Pautier | 1000 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
4 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| 3 | Spencer Pautier | 1000 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
4 rows in set (0.00 sec)
|
||||
```
|
@ -10,9 +10,10 @@ localeTitle: حقن SQL
|
||||
|
||||
المثال التالي هو أحد مقتطفات التعليمات البرمجية التي سيتم استرداد مستخدم من قاعدة بيانات تستند إلى `AccountId` .
|
||||
|
||||
`passedInAccountId = getRequestString("AccountId");
|
||||
sql = "select * from Accounts where AccountId = " + passedInAccountId;
|
||||
`
|
||||
```
|
||||
passedInAccountId = getRequestString("AccountId");
|
||||
sql = "select * from Accounts where AccountId = " + passedInAccountId;
|
||||
```
|
||||
|
||||
يمكن استخدام حقن SQL لخرق هذا الرمز عن طريق حقن `1=1;` بيان `AccountId` .
|
||||
|
||||
|
@ -24,15 +24,17 @@ localeTitle: SQL الداخلية الانضمام إلى الكلمات الر
|
||||
|
||||
"انضم" البيانات \`\` \`النص + ----------- + ------------------------ + ------------ ------ + -------------------- + -------------------- + | studentID | FullName | programOfStudy | خلية هاتف الطالب student-US-zipcode | + ----------- + ------------------------ + ------------ ------ + -------------------- + -------------------- + | 1 | مونيك ديفيز الأدب | 555-555-5551 | 97111 | | 2 | تيري جوتيريز | برمجة | 555-555-5552 | 97112 | | 3 | سبنسر باوتير | برمجة | 555-555-5553 | 97113 | | 4 | لويس رمزي برمجة | 555-555-5554 | 97114 | | 5 | ألفين غرين | برمجة | 555-555-5555 | 97115 | | 6 | صوفي فريمان برمجة | 555-555-5556 | 97116 | | 7 | إدغار فرانك "تيد" كود علوم الكمبيوتر | 555-555-5557 | 97117 | | 8 | دونالد د. شامبرلين علوم الكمبيوتر | 555-555-5558 | 97118 | + ----------- + ------------------------ + ------------ ------ + -------------------- + -------------------- +
|
||||
|
||||
`### Complete table listings for reference
|
||||
|
||||
Student table SQL
|
||||
`
|
||||
```
|
||||
### Complete table listings for reference
|
||||
|
||||
Student table SQL
|
||||
```
|
||||
|
||||
مزود SELECT a.studentID، a.FullName، sat\_score، a.programOfStudy، schoolEmailAdr من الطالب AS
|
||||
|
||||
`student or LEFT table
|
||||
`
|
||||
```
|
||||
student or LEFT table
|
||||
```
|
||||
|
||||
نص + ----------- + ------------------------ + ----------- + ------------------ + ------------------------ + | studentID | FullName | sat\_score | programOfStudy | schoolEmailAdr | + ----------- + ------------------------ + ----------- + ------------------ + ------------------------ + | 1 | مونيك ديفيز 400 | الأدب | Monique@someSchool.edu | | 2 | تيري جوتيريز | 800 | برمجة | Teri@someSchool.edu | | 3 | سبنسر باوتير | 1000 | برمجة | Spencer@someSchool.edu | | 4 | لويس رمزي 1200 | برمجة | Louis@someSchool.edu | | 5 | ألفين غرين | 1200 | برمجة | Alvin@someSchool.edu | | 6 | صوفي فريمان 1200 | برمجة | Sophie@someSchool.edu | | 7 | إدغار فرانك "تيد" كود 2400 | علوم الكمبيوتر | Edgar@someSchool.edu | | 8 | دونالد د. شامبرلين 2400 | علوم الكمبيوتر | Donald@someSchool.edu | | 9 | ريمون ف. بويس 2400 | علوم الكمبيوتر | Raymond@someSchool.edu | + ----------- + ------------------------ + ----------- + ------------------ + ------------------------ + 9 صفوف في مجموعة (0.00 ثانية)
|
||||
|
||||
|
@ -8,11 +8,12 @@ localeTitle: إدراج SQL في تحديد البيان
|
||||
|
||||
يجمع `INSERT INTO SELECT` بين `INSERT INTO` و `SELECT` ، ويمكنك استخدام أي شروط تريدها. الصيغة هي:
|
||||
|
||||
`INSERT INTO table2 (column1, column2, column3, ...)
|
||||
SELECT column1, column2, column3, ...
|
||||
FROM table1
|
||||
WHERE condition;
|
||||
`
|
||||
```sql
|
||||
INSERT INTO table2 (column1, column2, column3, ...)
|
||||
SELECT column1, column2, column3, ...
|
||||
FROM table1
|
||||
WHERE condition;
|
||||
```
|
||||
|
||||
هنا مثال يحتذى به في الجدول الشخص كل الطلاب الذكور من الجدول الطلاب.
|
||||
|
||||
|
@ -8,15 +8,17 @@ localeTitle: إدراج SQL في بيان
|
||||
|
||||
يمكنك القيام بذلك بطريقتين ، إذا أردت إدراج قيم في بعض الأعمدة فقط ، فيجب عليك إدراج أسمائها بما في ذلك جميع الأعمدة الإلزامية. الصيغة هي:
|
||||
|
||||
`INSERT INTO table_name (column1, column2, column3, ...)
|
||||
VALUES (value1, value2, value3, ...);
|
||||
`
|
||||
```sql
|
||||
INSERT INTO table_name (column1, column2, column3, ...)
|
||||
VALUES (value1, value2, value3, ...);
|
||||
```
|
||||
|
||||
والطريقة الأخرى هي إدراج قيم لجميع الأعمدة في الجدول ، وليس من الضروري تحديد أسماء الأعمدة. الصيغة هي:
|
||||
|
||||
`INSERT INTO table_name
|
||||
VALUES (value1, value2, value3, ...);
|
||||
`
|
||||
```sql
|
||||
INSERT INTO table_name
|
||||
VALUES (value1, value2, value3, ...);
|
||||
```
|
||||
|
||||
في ما يلي مثال على إدراج سجل في الجدول الشخص بطريقتين:
|
||||
|
||||
|
@ -8,51 +8,56 @@ localeTitle: أسئلة مقابلة SQL
|
||||
|
||||
هذا هو نوع الارتباط الافتراضي إذا لم يتم تحديد صلة. تقوم بإرجاع كافة الصفوف التي توجد تطابق واحد على الأقل في كلا الجدولين.
|
||||
|
||||
`SELECT * FROM A x JOIN B y ON y.aId = x.Id
|
||||
`
|
||||
```sql
|
||||
SELECT * FROM A x JOIN B y ON y.aId = x.Id
|
||||
```
|
||||
|
||||
### ما هو انضمام اليسار في SQL؟
|
||||
|
||||
يقوم الرابط الأيسر بإرجاع جميع الصفوف من الجدول الأيسر ، والصفوف المتطابقة من الجدول الصحيح. سيتم إرجاع الصفوف في الجدول الأيسر حتى في حالة عدم وجود تطابق في الجدول الصحيح. الصفوف من الجدول الأيسر بدون تطابق في الجدول الصحيح ستكون `null` لقيم الجدول الصحيح.
|
||||
|
||||
`SELECT * FROM A x LEFT JOIN B y ON y.aId = x.Id
|
||||
`
|
||||
```sql
|
||||
SELECT * FROM A x LEFT JOIN B y ON y.aId = x.Id
|
||||
```
|
||||
|
||||
### ما هو الانضمام الصحيح في SQL؟
|
||||
|
||||
يقوم الربط الأيمن بإرجاع جميع الصفوف من الجدول الصحيح والصفوف المتطابقة من الجدول الأيسر. مقابل صلة اليسار ، سيؤدي هذا إلى إرجاع كافة الصفوف من الجدول الصحيح حتى عندما لا يوجد تطابق في الجدول الأيسر. الصفوف في الجدول الأيمن التي ليس لها أي تطابق في الجدول الأيسر سيكون لها قيم `null` الجدول الأيسر.
|
||||
|
||||
`SELECT * FROM A x RIGHT JOIN B y ON y.aId = x.Id
|
||||
`
|
||||
```sql
|
||||
SELECT * FROM A x RIGHT JOIN B y ON y.aId = x.Id
|
||||
```
|
||||
|
||||
### ما هو الانضمام الكامل في SQL؟
|
||||
|
||||
إرجاع صلة كاملة كافة الصفوف التي توجد تطابق في أي من الجداول. لذلك إذا كانت هناك صفوف في الجدول الأيسر لا تحتوي على تطابقات في الجدول الصحيح ، فسيتم تضمينها. وكذلك إذا كانت هناك صفوف في الجدول الأيمن لا تحتوي على تطابقات في الجدول الأيسر ، فسيتم تضمينها.
|
||||
|
||||
`SELECT Customers.CustomerName, Orders.OrderID
|
||||
FROM Customers
|
||||
FULL OUTER JOIN Orders
|
||||
ON Customers.CustomerID=Orders.CustomerID
|
||||
ORDER BY Customers.CustomerName
|
||||
`
|
||||
```sql
|
||||
SELECT Customers.CustomerName, Orders.OrderID
|
||||
FROM Customers
|
||||
FULL OUTER JOIN Orders
|
||||
ON Customers.CustomerID=Orders.CustomerID
|
||||
ORDER BY Customers.CustomerName
|
||||
```
|
||||
|
||||
### ما هي نتيجة الأمر التالي؟
|
||||
|
||||
\`\` \` إسقاط عرض view\_name
|
||||
|
||||
`Here it'll be an error because we can't perform a DML operation on a view.
|
||||
|
||||
### Can we perform a rollback after using ALTER command?
|
||||
No, because ALTER is a DDL command and Oracle server performs an automatic COMMIT when the DDL statements are executed.
|
||||
|
||||
|
||||
### Which is the only constraint that enforces rules at column level?
|
||||
NOT NULL is the only constraint that works at the column level.
|
||||
|
||||
|
||||
### What are the pseudocolumns in SQL? Give some examples?
|
||||
A pseudocolumn is a function which returns a system generated value. The reason it is known as so because a pseudocolumn is an Oracle assigned value used in the same context as an Oracle database column but not stored on disk.
|
||||
`
|
||||
```
|
||||
Here it'll be an error because we can't perform a DML operation on a view.
|
||||
|
||||
### Can we perform a rollback after using ALTER command?
|
||||
No, because ALTER is a DDL command and Oracle server performs an automatic COMMIT when the DDL statements are executed.
|
||||
|
||||
|
||||
### Which is the only constraint that enforces rules at column level?
|
||||
NOT NULL is the only constraint that works at the column level.
|
||||
|
||||
|
||||
### What are the pseudocolumns in SQL? Give some examples?
|
||||
A pseudocolumn is a function which returns a system generated value. The reason it is known as so because a pseudocolumn is an Oracle assigned value used in the same context as an Oracle database column but not stored on disk.
|
||||
```
|
||||
|
||||
بعض الأمثلة على ذلك هي: ROWNUM، ROWID، USER، CURRVAL، NEXTVAL etc. \`\` \`
|
||||
|
||||
@ -114,8 +119,9 @@ localeTitle: أسئلة مقابلة SQL
|
||||
هنا خيار CASCADE ضروري لإزالة كافة كائنات المستخدم في قاعدة البيانات. \`\` \`sql
|
||||
انخفاض المستخدم ريتا CASCADE
|
||||
|
||||
`### Write SQL query to find the nth highest salary from table.
|
||||
`
|
||||
```
|
||||
### Write SQL query to find the nth highest salary from table.
|
||||
```
|
||||
|
||||
مزود
|
||||
SELECT TOP 1 الراتب من عند ( SELECT DISTINCT TOP N Salary من الموظف ORDER BY Salary DESC ) ORDER BY الراتب ASC \`\` \`
|
@ -10,11 +10,12 @@ localeTitle: ينضم SQL
|
||||
|
||||
### بناء جملة SQL مع التركيز على الانضمام
|
||||
|
||||
`SELECT col1, col2, col3, etc....
|
||||
FROM tableNameOne AS a
|
||||
JOIN tableNameTwo AS b ON a.primeKey = b.primeKey
|
||||
etc...
|
||||
`
|
||||
```sql
|
||||
SELECT col1, col2, col3, etc....
|
||||
FROM tableNameOne AS a
|
||||
JOIN tableNameTwo AS b ON a.primeKey = b.primeKey
|
||||
etc...
|
||||
```
|
||||
|
||||
يمكن أن يكون عبارة JOIN مجرد JOIN أو INNER JOIN ، والتي هي نفسها ، أو LEFT JOIN (الموضحة أدناه).
|
||||
|
||||
@ -49,11 +50,12 @@ localeTitle: ينضم SQL
|
||||
|
||||
بيانات "انضم": \`\` \`النص + ----------- + ------------------------ + ------------ ------ + -------------------- + -------------------- + | studentID | FullName | programOfStudy | خلية هاتف الطالب student-US-zipcode | + ----------- + ------------------------ + ------------ ------ + -------------------- + -------------------- + | 1 | مونيك ديفيز الأدب | 555-555-5551 | 97111 | | 2 | تيري جوتيريز | برمجة | 555-555-5552 | 97112 | | 3 | سبنسر باوتير | برمجة | 555-555-5553 | 97113 | | 4 | لويس رمزي برمجة | 555-555-5554 | 97114 | | 5 | ألفين غرين | برمجة | 555-555-5555 | 97115 | | 6 | صوفي فريمان برمجة | 555-555-5556 | 97116 | | 7 | إدغار فرانك "تيد" كود علوم الكمبيوتر | 555-555-5557 | 97117 | | 8 | دونالد د. شامبرلين علوم الكمبيوتر | 555-555-5558 | 97118 | + ----------- + ------------------------ + ------------ ------ + -------------------- + -------------------- +
|
||||
|
||||
`### Left Join
|
||||
Using the keyword LEFT before JOIN causes the system to start with the student (LEFT) table but will return NULL from the RIGHT table if there are no rows for the LEFT table student.
|
||||
|
||||
Note that studentID 9 appears here but the data from the contact table is just shown as NULL.
|
||||
`
|
||||
```
|
||||
### Left Join
|
||||
Using the keyword LEFT before JOIN causes the system to start with the student (LEFT) table but will return NULL from the RIGHT table if there are no rows for the LEFT table student.
|
||||
|
||||
Note that studentID 9 appears here but the data from the contact table is just shown as NULL.
|
||||
```
|
||||
|
||||
مزود حدد a.studentID ، a.FullName ، a.programOfStudy ، ب. `student-phone-cell` ، ب. `student-US-zipcode` من الطالب ك LEFT JOIN `student-contact-info` AS b ON a.studentID = b.studentID؛
|
||||
|
||||
@ -78,32 +80,35 @@ localeTitle: ينضم SQL
|
||||
|
||||
قوائم جدول الطلاب
|
||||
|
||||
`SELECT a.studentID, a.FullName, sat_score, a.programOfStudy, schoolEmailAdr
|
||||
FROM student AS a;
|
||||
`
|
||||
```sql
|
||||
SELECT a.studentID, a.FullName, sat_score, a.programOfStudy, schoolEmailAdr
|
||||
FROM student AS a;
|
||||
```
|
||||
|
||||
طالب أو يسار الجدول
|
||||
|
||||
`+-----------+------------------------+-----------+------------------+------------------------+
|
||||
| studentID | FullName | sat_score | programOfStudy | schoolEmailAdr |
|
||||
+-----------+------------------------+-----------+------------------+------------------------+
|
||||
| 1 | Monique Davis | 400 | Literature | Monique@someSchool.edu |
|
||||
| 2 | Teri Gutierrez | 800 | Programming | Teri@someSchool.edu |
|
||||
| 3 | Spencer Pautier | 1000 | Programming | Spencer@someSchool.edu |
|
||||
| 4 | Louis Ramsey | 1200 | Programming | Louis@someSchool.edu |
|
||||
| 5 | Alvin Greene | 1200 | Programming | Alvin@someSchool.edu |
|
||||
| 6 | Sophie Freeman | 1200 | Programming | Sophie@someSchool.edu |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | Computer Science | Edgar@someSchool.edu |
|
||||
| 8 | Donald D. Chamberlin | 2400 | Computer Science | Donald@someSchool.edu |
|
||||
| 9 | Raymond F. Boyce | 2400 | Computer Science | Raymond@someSchool.edu |
|
||||
+-----------+------------------------+-----------+------------------+------------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+------------------------+-----------+------------------+------------------------+
|
||||
| studentID | FullName | sat_score | programOfStudy | schoolEmailAdr |
|
||||
+-----------+------------------------+-----------+------------------+------------------------+
|
||||
| 1 | Monique Davis | 400 | Literature | Monique@someSchool.edu |
|
||||
| 2 | Teri Gutierrez | 800 | Programming | Teri@someSchool.edu |
|
||||
| 3 | Spencer Pautier | 1000 | Programming | Spencer@someSchool.edu |
|
||||
| 4 | Louis Ramsey | 1200 | Programming | Louis@someSchool.edu |
|
||||
| 5 | Alvin Greene | 1200 | Programming | Alvin@someSchool.edu |
|
||||
| 6 | Sophie Freeman | 1200 | Programming | Sophie@someSchool.edu |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | Computer Science | Edgar@someSchool.edu |
|
||||
| 8 | Donald D. Chamberlin | 2400 | Computer Science | Donald@someSchool.edu |
|
||||
| 9 | Raymond F. Boyce | 2400 | Computer Science | Raymond@someSchool.edu |
|
||||
+-----------+------------------------+-----------+------------------+------------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
مزود SELECT \* from `student-contact-info` AS b؛
|
||||
|
||||
`student contact or RIGHT table
|
||||
`
|
||||
```
|
||||
student contact or RIGHT table
|
||||
```
|
||||
|
||||
نص + ----------- + ---------------------------------- + - ------------------ + -------------------- + | studentID | studentEmailAddr | خلية هاتف الطالب student-US-zipcode | + ----------- + ---------------------------------- + - ------------------ + -------------------- + | 1 | Monique.Davis@freeCodeCamp.org | 555-555-5551 | 97111 | | 2 | Teri.Gutierrez@freeCodeCamp.org | 555-555-5552 | 97112 | | 3 | Spencer.Pautier@freeCodeCamp.org | 555-555-5553 | 97113 | | 4 | Louis.Ramsey@freeCodeCamp.org | 555-555-5554 | 97114 | | 5 | Alvin.Green@freeCodeCamp.org | 555-555-5555 | 97115 | | 6 | Sophie.Freeman@freeCodeCamp.org | 555-555-5556 | 97116 | | 7 | Maximo.Smith@freeCodeCamp.org | 555-555-5557 | 97117 | | 8 | Michael.Roach@freeCodeCamp.ort | 555-555-5558 | 97118 | + ----------- + ---------------------------------- + - ------------------ + -------------------- + 8 صفوف في مجموعة (0.00 ثانية) \`\` \`
|
||||
|
||||
|
@ -22,14 +22,16 @@ localeTitle: SQL Left Join
|
||||
|
||||
\`\` \`النص + ----------- + ------------------------ + ------------ ------ + -------------------- + -------------------- + | studentID | FullName | programOfStudy | خلية هاتف الطالب student-US-zipcode | + ----------- + ------------------------ + ------------ ------ + -------------------- + -------------------- + | 1 | مونيك ديفيز الأدب | 555-555-5551 | 97111 | | 2 | تيري جوتيريز | برمجة | 555-555-5552 | 97112 | | 3 | سبنسر باوتير | برمجة | 555-555-5553 | 97113 | | 4 | لويس رمزي برمجة | 555-555-5554 | 97114 | | 5 | ألفين غرين | برمجة | 555-555-5555 | 97115 | | 6 | صوفي فريمان برمجة | 555-555-5556 | 97116 | | 7 | إدغار فرانك "تيد" كود علوم الكمبيوتر | 555-555-5557 | 97117 | | 8 | دونالد د. شامبرلين علوم الكمبيوتر | 555-555-5558 | 97118 | | 9 | ريمون ف. بويس علوم الكمبيوتر | فارغة فارغة + ----------- + ------------------------ + ------------ ------ + -------------------- + -------------------- + 9 صفوف في مجموعة (0.00 ثانية)
|
||||
|
||||
`### Complete table listings for reference
|
||||
student or LEFT table SQL
|
||||
`
|
||||
```
|
||||
### Complete table listings for reference
|
||||
student or LEFT table SQL
|
||||
```
|
||||
|
||||
مزود SELECT a.studentID، a.FullName، sat\_score، a.programOfStudy، schoolEmailAdr من الطالب AS
|
||||
|
||||
`student or LEFT table data
|
||||
`
|
||||
```
|
||||
student or LEFT table data
|
||||
```
|
||||
|
||||
نص + ----------- + ------------------------ + ----------- + ------------------ + ------------------------ + | studentID | FullName | sat\_score | programOfStudy | schoolEmailAdr | + ----------- + ------------------------ + ----------- + ------------------ + ------------------------ + | 1 | مونيك ديفيز 400 | الأدب | Monique@someSchool.edu | | 2 | تيري جوتيريز | 800 | برمجة | Teri@someSchool.edu | | 3 | سبنسر باوتير | 1000 | برمجة | Spencer@someSchool.edu | | 4 | لويس رمزي 1200 | برمجة | Louis@someSchool.edu | | 5 | ألفين غرين | 1200 | برمجة | Alvin@someSchool.edu | | 6 | صوفي فريمان 1200 | برمجة | Sophie@someSchool.edu | | 7 | إدغار فرانك "تيد" كود 2400 | علوم الكمبيوتر | Edgar@someSchool.edu | | 8 | دونالد د. شامبرلين 2400 | علوم الكمبيوتر | Donald@someSchool.edu | | 9 | ريمون ف. بويس 2400 | علوم الكمبيوتر | Raymond@someSchool.edu | + ----------- + ------------------------ + ----------- + ------------------ + ------------------------ + 9 صفوف في مجموعة (0.00 ثانية)
|
||||
|
||||
|
@ -18,66 +18,73 @@ localeTitle: SQL LIKE المشغل
|
||||
|
||||
سيحدد هذا SQL الطلاب الذين لديهم `FullName` بدءًا من "Monique" أو تنتهي بـ "Greene".
|
||||
|
||||
`SELECT studentID, FullName, sat_score, rcd_updated
|
||||
FROM student
|
||||
WHERE
|
||||
FullName LIKE 'Monique%' OR -- note the % at the end but not the beginning
|
||||
FullName LIKE '%Greene'; -- note the % at the beginning but not the end
|
||||
`
|
||||
```sql
|
||||
SELECT studentID, FullName, sat_score, rcd_updated
|
||||
FROM student
|
||||
WHERE
|
||||
FullName LIKE 'Monique%' OR -- note the % at the end but not the beginning
|
||||
FullName LIKE '%Greene'; -- note the % at the beginning but not the end
|
||||
```
|
||||
|
||||
`+-----------+---------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+---------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
+-----------+---------------+-----------+---------------------+
|
||||
2 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+---------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+---------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
+-----------+---------------+-----------+---------------------+
|
||||
2 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
### يوجد نمط سلسلة في منتصف العمود
|
||||
|
||||
سيحدد هذا SQL الطلاب الذين لديهم "ree" في أي مكان في الاسم.
|
||||
|
||||
`SELECT studentID, FullName, sat_score, rcd_updated
|
||||
FROM student
|
||||
WHERE FullName LIKE '%ree%'; -- note the % at the beginning AND at the end
|
||||
`
|
||||
```sql
|
||||
SELECT studentID, FullName, sat_score, rcd_updated
|
||||
FROM student
|
||||
WHERE FullName LIKE '%ree%'; -- note the % at the beginning AND at the end
|
||||
```
|
||||
|
||||
`+-----------+----------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+----------------+-----------+---------------------+
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
+-----------+----------------+-----------+---------------------+
|
||||
2 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+----------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+----------------+-----------+---------------------+
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
+-----------+----------------+-----------+---------------------+
|
||||
2 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
### السلسلة ليست في العمود
|
||||
|
||||
يمكنك وضع "NOT" قبل LIKE لاستبعاد الصفوف بنمط السلسلة بدلاً من تحديدها. يستثني هذا SQL السجلات التي تحتوي على "cer Pau" و "Ted" في العمود FullName.
|
||||
|
||||
`SELECT studentID, FullName, sat_score, rcd_updated
|
||||
FROM student
|
||||
WHERE FullName NOT LIKE '%cer Pau%' AND FullName NOT LIKE '%"Ted"%';
|
||||
`
|
||||
```sql
|
||||
SELECT studentID, FullName, sat_score, rcd_updated
|
||||
FROM student
|
||||
WHERE FullName NOT LIKE '%cer Pau%' AND FullName NOT LIKE '%"Ted"%';
|
||||
```
|
||||
|
||||
`+-----------+----------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
7 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
7 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
_في ما يلي قائمة الطلاب الكاملة الحالية للمقارنة مع مكان تعيين نتيجة الجملة أعلاه._
|
||||
|
||||
`SELECT studentID, FullName, sat_score, rcd_updated FROM student;
|
||||
`
|
||||
```sql
|
||||
SELECT studentID, FullName, sat_score, rcd_updated FROM student;
|
||||
```
|
||||
|
||||
\`\` \`النص + ----------- + ------------------------ + ----------- + --------------------- + | studentID | FullName | _درجة_ جلس _|_ تحديث _Rcd_ | + ----------- + ------------------------ + ----------- + --------------------- + | 1 | مونيك ديفيز 400 | 2017-08-16 15:34:50 | | 2 | تيري جوتيريز | 800 | 2017-08-16 15:34:50 | | 3 | سبنسر باوتير | 1000 | 2017-08-16 15:34:50 | | 4 | لويس رمزي 1200 | 2017-08-16 15:34:50 | | 5 | ألفين غرين | 1200 | 2017-08-16 15:34:50 | | 6 | صوفي فريمان 1200 | 2017-08-16 15:34:50 | | 7 | إدغار فرانك "تيد" كود 2400 | 2017-08-16 15:35:33 | | 8 | دونالد د. شامبرلين 2400 | 2017-08-16 15:35:33 | | 9 | ريمون ف. بويس 2400 | 2017-08-16 15:35:33 | + ----------- + ------------------------ + ----------- + --------------------- + 9 صفوف في مجموعة (0.00 ثانية)
|
@ -8,7 +8,8 @@ localeTitle: SQL لا المشغل
|
||||
|
||||
في ما يلي مثال يختار جميع الأشخاص غير الذكور:
|
||||
|
||||
`SELECT Id, Name, DateOfBirth, Gender
|
||||
FROM Person
|
||||
WHERE NOT Gender = "M"
|
||||
`
|
||||
```sql
|
||||
SELECT Id, Name, DateOfBirth, Gender
|
||||
FROM Person
|
||||
WHERE NOT Gender = "M"
|
||||
```
|
@ -8,16 +8,18 @@ localeTitle: SQL أو المشغل
|
||||
|
||||
في ما يلي مثال يحدد جميع السجلات من جدول "الأشخاص" الذين هم إما ذكور أو الذين لديهم اسم "ماري":
|
||||
|
||||
`SELECT Id, Name, DateOfBirth, Gender
|
||||
FROM Person
|
||||
WHERE Gender = “M” OR Name = “Mary”
|
||||
`
|
||||
```sql
|
||||
SELECT Id, Name, DateOfBirth, Gender
|
||||
FROM Person
|
||||
WHERE Gender = “M” OR Name = “Mary”
|
||||
```
|
||||
|
||||
يمكنك دمج عوامل تشغيل أخرى في `WHERE` (استخدم الأقواس للإشارة إلى ترتيب العمليات) كما في هذا المثال:
|
||||
|
||||
`SELECT Id, Name, DateOfBirth, Gender
|
||||
FROM Person
|
||||
WHERE Gender = “M” AND (Name = “Peter” OR Name = “John”)
|
||||
`
|
||||
```sql
|
||||
SELECT Id, Name, DateOfBirth, Gender
|
||||
FROM Person
|
||||
WHERE Gender = “M” AND (Name = “Peter” OR Name = “John”)
|
||||
```
|
||||
|
||||
يختار هذا المثال جميع السجلات التي يكون فيها الجنس "M" والاسم "Peter" ، وكذلك الجنس حيث يكون "M" والاسم "John".
|
@ -8,47 +8,51 @@ localeTitle: ترتيب SQL بالكلمات الرئيسية
|
||||
|
||||
ORDER BY يعطينا طريقة ل SORT النتيجة المحددة بواسطة واحد أو أكثر من العناصر في قسم SELECT. هنا هو مزود فرز الفرز للطلاب من خلال FullName بترتيب تنازلي. ترتيب الفرز الافتراضي هو تصاعدي (ASC) ولكن لفرز بالترتيب المعاكس (تنازلي) تستخدم DESC.
|
||||
|
||||
`SELECT studentID, FullName, sat_score
|
||||
FROM student
|
||||
ORDER BY FullName DESC;
|
||||
`
|
||||
```sql
|
||||
SELECT studentID, FullName, sat_score
|
||||
FROM student
|
||||
ORDER BY FullName DESC;
|
||||
```
|
||||
|
||||
`+-----------+------------------------+-----------+
|
||||
| studentID | FullName | sat_score |
|
||||
+-----------+------------------------+-----------+
|
||||
| 2 | Teri Gutierrez | 800 |
|
||||
| 3 | Spencer Pautier | 1000 |
|
||||
| 6 | Sophie Freeman | 1200 |
|
||||
| 9 | Raymond F. Boyce | 2400 |
|
||||
| 1 | Monique Davis | 400 |
|
||||
| 4 | Louis Ramsey | 1200 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 |
|
||||
| 8 | Donald D. Chamberlin | 2400 |
|
||||
| 5 | Alvin Greene | 1200 |
|
||||
+-----------+------------------------+-----------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+------------------------+-----------+
|
||||
| studentID | FullName | sat_score |
|
||||
+-----------+------------------------+-----------+
|
||||
| 2 | Teri Gutierrez | 800 |
|
||||
| 3 | Spencer Pautier | 1000 |
|
||||
| 6 | Sophie Freeman | 1200 |
|
||||
| 9 | Raymond F. Boyce | 2400 |
|
||||
| 1 | Monique Davis | 400 |
|
||||
| 4 | Louis Ramsey | 1200 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 |
|
||||
| 8 | Donald D. Chamberlin | 2400 |
|
||||
| 5 | Alvin Greene | 1200 |
|
||||
+-----------+------------------------+-----------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
_وفيما يلي قائمة الطلاب المسجلين من الأمم المتحدة ، الحالية ، الكاملة للمقارنة مع ما سبق._
|
||||
|
||||
`SELECT studentID, FullName, sat_score, rcd_updated FROM student;
|
||||
`
|
||||
```sql
|
||||
SELECT studentID, FullName, sat_score, rcd_updated FROM student;
|
||||
```
|
||||
|
||||
`+-----------+------------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
كما هو الحال مع كل هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي.
|
||||
|
||||
|
@ -22,12 +22,13 @@ localeTitle: SQL مفتاح القيد الرئيسي
|
||||
|
||||
فيما يلي أمر إنشاء جدول يقوم أيضًا بإنشاء مفتاح أساسي باستخدام حقلين.
|
||||
|
||||
`CREATE TABLE priKeyExample(
|
||||
rcdKey_id_a INT NOT NULL,
|
||||
rcdKeySeq_id INT NOT NULL,
|
||||
someData varchar(256) NOT NULL,
|
||||
PRIMARY KEY(rcdKey_id_a,rcdKeySeq_id));
|
||||
`
|
||||
```sql
|
||||
CREATE TABLE priKeyExample(
|
||||
rcdKey_id_a INT NOT NULL,
|
||||
rcdKeySeq_id INT NOT NULL,
|
||||
someData varchar(256) NOT NULL,
|
||||
PRIMARY KEY(rcdKey_id_a,rcdKeySeq_id));
|
||||
```
|
||||
|
||||
### مثال مع جدول التغيير
|
||||
|
||||
@ -38,9 +39,10 @@ localeTitle: SQL مفتاح القيد الرئيسي
|
||||
|
||||
الآن سنقوم بإضافة واحدة جديدة.
|
||||
|
||||
`ALTER TABLE priKeyExample
|
||||
ADD CONSTRAINT myPriKey PRIMARY KEY(rcdKey_id_a,rcdKeySeq_id);
|
||||
`
|
||||
```sql
|
||||
ALTER TABLE priKeyExample
|
||||
ADD CONSTRAINT myPriKey PRIMARY KEY(rcdKey_id_a,rcdKeySeq_id);
|
||||
```
|
||||
|
||||
كما هو الحال مع كل هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي.
|
||||
|
||||
|
@ -14,11 +14,12 @@ A View هو كائن قاعدة بيانات يقدم البيانات من جد
|
||||
|
||||
### Sytax العام
|
||||
|
||||
`CREATE OR REPLACE VIEW view_name AS
|
||||
SELECT column1, column2, ...
|
||||
FROM table_name
|
||||
WHERE condition;
|
||||
`
|
||||
```sql
|
||||
CREATE OR REPLACE VIEW view_name AS
|
||||
SELECT column1, column2, ...
|
||||
FROM table_name
|
||||
WHERE condition;
|
||||
```
|
||||
|
||||
### يستخدم SQL لإنشاء العرض والبيانات الحالية
|
||||
|
||||
@ -33,32 +34,35 @@ A View هو كائن قاعدة بيانات يقدم البيانات من جد
|
||||
|
||||
البيانات الحالية:
|
||||
|
||||
`+-----------------+----------------+
|
||||
| FullName | programOfStudy |
|
||||
+-----------------+----------------+
|
||||
| Teri Gutierrez | Programming |
|
||||
| Spencer Pautier | Programming |
|
||||
| Louis Ramsey | Programming |
|
||||
| Alvin Greene | Programming |
|
||||
| Sophie Freeman | Programming |
|
||||
+-----------------+----------------+
|
||||
5 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------------+----------------+
|
||||
| FullName | programOfStudy |
|
||||
+-----------------+----------------+
|
||||
| Teri Gutierrez | Programming |
|
||||
| Spencer Pautier | Programming |
|
||||
| Louis Ramsey | Programming |
|
||||
| Alvin Greene | Programming |
|
||||
| Sophie Freeman | Programming |
|
||||
+-----------------+----------------+
|
||||
5 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
قائمة من وجهات النظر الحالية:
|
||||
|
||||
`SHOW FULL TABLES IN fcc_sql_guides_database WHERE TABLE_TYPE LIKE 'VIEW';
|
||||
`
|
||||
```sql
|
||||
SHOW FULL TABLES IN fcc_sql_guides_database WHERE TABLE_TYPE LIKE 'VIEW';
|
||||
```
|
||||
|
||||
`+-----------------------------------+------------+
|
||||
| Tables_in_fcc_sql_guides_database | Table_type |
|
||||
+-----------------------------------+------------+
|
||||
| programming-students-v | VIEW |
|
||||
| students-contact-info_v | VIEW |
|
||||
| students_dropme_v | VIEW |
|
||||
+-----------------------------------+------------+
|
||||
3 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------------------------------+------------+
|
||||
| Tables_in_fcc_sql_guides_database | Table_type |
|
||||
+-----------------------------------+------------+
|
||||
| programming-students-v | VIEW |
|
||||
| students-contact-info_v | VIEW |
|
||||
| students_dropme_v | VIEW |
|
||||
+-----------------------------------+------------+
|
||||
3 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
### استبدال العرض
|
||||
|
||||
@ -73,28 +77,30 @@ A View هو كائن قاعدة بيانات يقدم البيانات من جد
|
||||
|
||||
ملاحظة: تعرض طريقة العرض الآن sat\_score.
|
||||
|
||||
`+-----------------+----------------+-----------+
|
||||
| FullName | programOfStudy | sat_score |
|
||||
+-----------------+----------------+-----------+
|
||||
| Teri Gutierrez | Programming | 800 |
|
||||
| Spencer Pautier | Programming | 1000 |
|
||||
| Louis Ramsey | Programming | 1200 |
|
||||
| Alvin Greene | Programming | 1200 |
|
||||
| Sophie Freeman | Programming | 1200 |
|
||||
+-----------------+----------------+-----------+
|
||||
`
|
||||
```text
|
||||
+-----------------+----------------+-----------+
|
||||
| FullName | programOfStudy | sat_score |
|
||||
+-----------------+----------------+-----------+
|
||||
| Teri Gutierrez | Programming | 800 |
|
||||
| Spencer Pautier | Programming | 1000 |
|
||||
| Louis Ramsey | Programming | 1200 |
|
||||
| Alvin Greene | Programming | 1200 |
|
||||
| Sophie Freeman | Programming | 1200 |
|
||||
+-----------------+----------------+-----------+
|
||||
```
|
||||
|
||||
ملاحظة: قائمة وجهات النظر لم تتغير ، يتم استبدال وجهة نظرنا.
|
||||
|
||||
`mysql> SHOW FULL TABLES IN fcc_sql_guides_database WHERE TABLE_TYPE LIKE 'VIEW';
|
||||
+-----------------------------------+------------+
|
||||
| Tables_in_fcc_sql_guides_database | Table_type |
|
||||
+-----------------------------------+------------+
|
||||
| programming-students-v | VIEW |
|
||||
| students-contact-info_v | VIEW |
|
||||
| students_dropme_v | VIEW |
|
||||
+-----------------------------------+------------+
|
||||
3 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
mysql> SHOW FULL TABLES IN fcc_sql_guides_database WHERE TABLE_TYPE LIKE 'VIEW';
|
||||
+-----------------------------------+------------+
|
||||
| Tables_in_fcc_sql_guides_database | Table_type |
|
||||
+-----------------------------------+------------+
|
||||
| programming-students-v | VIEW |
|
||||
| students-contact-info_v | VIEW |
|
||||
| students_dropme_v | VIEW |
|
||||
+-----------------------------------+------------+
|
||||
3 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
\* كما هو الحال مع جميع هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي. آمل أن يمنحك هذا على الأقل ما يكفي للبدء. يرجى الاطلاع على دليل مدير قاعدة البيانات الخاص بك والمتعة محاولة خيارات مختلفة بنفسك.
|
@ -12,42 +12,46 @@ localeTitle: مزود حق الانضمام
|
||||
|
||||
تقوم الكلمة الأساسية RIGHT JOIN بإرجاع كافة السجلات من الجدول الصحيح (table2) ، والسجلات المتطابقة من الجدول الأيسر (table1). والنتيجة هي NULL من الجانب الأيسر ، عندما لا يكون هناك أي تطابق.
|
||||
|
||||
`SELECT *
|
||||
FROM table1
|
||||
RIGHT JOIN table2
|
||||
ON table1.column_name = table2.column_name;
|
||||
`
|
||||
```sql
|
||||
SELECT *
|
||||
FROM table1
|
||||
RIGHT JOIN table2
|
||||
ON table1.column_name = table2.column_name;
|
||||
```
|
||||
|
||||
### استكمال قوائم الجدول لتكون مرجعا
|
||||
|
||||
الغذاء أو بيانات الجدول الأيسر
|
||||
|
||||
`+---------+--------------+-----------+------------+
|
||||
| ITEM_ID | ITEM_NAME | ITEM_UNIT | COMPANY_ID |
|
||||
+---------+--------------+-----------+------------+
|
||||
| 1 | Chex Mix | Pcs | 16 |
|
||||
| 6 | Cheez-It | Pcs | 15 |
|
||||
| 2 | BN Biscuit | Pcs | 15 |
|
||||
| 3 | Mighty Munch | Pcs | 17 |
|
||||
| 4 | Pot Rice | Pcs | 15 |
|
||||
| 5 | Jaffa Cakes | Pcs | 18 |
|
||||
| 7 | Salt n Shake | Pcs | |
|
||||
+---------+--------------+-----------+------------+
|
||||
|
||||
|
||||
|
||||
company or RIGHT table data
|
||||
`
|
||||
```text
|
||||
+---------+--------------+-----------+------------+
|
||||
| ITEM_ID | ITEM_NAME | ITEM_UNIT | COMPANY_ID |
|
||||
+---------+--------------+-----------+------------+
|
||||
| 1 | Chex Mix | Pcs | 16 |
|
||||
| 6 | Cheez-It | Pcs | 15 |
|
||||
| 2 | BN Biscuit | Pcs | 15 |
|
||||
| 3 | Mighty Munch | Pcs | 17 |
|
||||
| 4 | Pot Rice | Pcs | 15 |
|
||||
| 5 | Jaffa Cakes | Pcs | 18 |
|
||||
| 7 | Salt n Shake | Pcs | |
|
||||
+---------+--------------+-----------+------------+
|
||||
|
||||
|
||||
|
||||
company or RIGHT table data
|
||||
```
|
||||
|
||||
نص + ------------ + --------------- + -------------- + | _معرف_ الشركة _|_ اسم _الشركة_ | COMPANY\_CITY | + ------------ + --------------- + -------------- + | 18 | ترتيب كل | بوسطن | 15 | جاك هيل المحدودة لندن | | 16 | أكاس للأغذية | دلهي | | 17 | عشاق الطعام. | لندن | | 19 | رشفة ن دغة. | نيويورك + ------------ + --------------- + -------------- +
|
||||
|
||||
`To get company name from company table and company ID, item name columns from foods table, the following SQL statement can be used:
|
||||
`
|
||||
```
|
||||
To get company name from company table and company ID, item name columns from foods table, the following SQL statement can be used:
|
||||
```
|
||||
|
||||
مزود SELECT company.company _id ، company.company_ name ، company.company _city، foods.company_ id، foods.item _name من الشركة الحق في الانضمام إلى الأطعمة على company.company_ id = foods.company\_id؛
|
||||
|
||||
`OUTPUT
|
||||
`
|
||||
```
|
||||
OUTPUT
|
||||
```
|
||||
|
||||
نص COMPANY _ID COMPANY_ NAME COMPANY _CITY COMPANY_ ID ITEM\_NAME
|
||||
|
||||
|
@ -10,40 +10,44 @@ localeTitle: SQL حدد بيان مميز
|
||||
|
||||
### عرض كامل للبيانات في جدول الطالب
|
||||
|
||||
`USE fcc_sql_guides_database;
|
||||
SELECT studentID, FullName, sat_score, programOfStudy, rcd_Created, rcd_Updated FROM student;
|
||||
`
|
||||
```sql
|
||||
USE fcc_sql_guides_database;
|
||||
SELECT studentID, FullName, sat_score, programOfStudy, rcd_Created, rcd_Updated FROM student;
|
||||
```
|
||||
|
||||
`+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
| studentID | FullName | sat_score | programOfStudy | rcd_Created | rcd_Updated |
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
| 1 | Monique Davis | 400 | Literature | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
| studentID | FullName | sat_score | programOfStudy | rcd_Created | rcd_Updated |
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
| 1 | Monique Davis | 400 | Literature | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
### الحصول على قائمة من مجالات الدراسة
|
||||
|
||||
`SELECT DISTINCT programOfStudy FROM student;
|
||||
`
|
||||
```sql
|
||||
SELECT DISTINCT programOfStudy FROM student;
|
||||
```
|
||||
|
||||
`+------------------+
|
||||
| programOfStudy |
|
||||
+------------------+
|
||||
| Literature |
|
||||
| Programming |
|
||||
| Computer Science |
|
||||
+------------------+
|
||||
3 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+------------------+
|
||||
| programOfStudy |
|
||||
+------------------+
|
||||
| Literature |
|
||||
| Programming |
|
||||
| Computer Science |
|
||||
+------------------+
|
||||
3 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
كما هو الحال مع كل هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي.
|
||||
|
||||
|
@ -10,25 +10,27 @@ localeTitle: تحديد بيان SQL
|
||||
|
||||
يوضح هذا المثال ثلاثة أعمدة محددة من جدول "الطالب" وعمود واحد محسوب. تقوم قاعدة البيانات بتخزين الطالب ID ، و FirstName ، و LastName للطالب. يمكننا دمج الأعمدة الأول واسم العائلة لإنشاء العمود المحتسب لـ FullName.
|
||||
|
||||
`select studentID, FirstName, LastName, FirstName + ' ' + LastName as FullName
|
||||
from student;
|
||||
`
|
||||
```sql
|
||||
select studentID, FirstName, LastName, FirstName + ' ' + LastName as FullName
|
||||
from student;
|
||||
```
|
||||
|
||||
`+-----------+-------------------+------------+------------------------+
|
||||
| studentID | FirstName | LastName | FullName |
|
||||
+-----------+-------------------+------------+------------------------+
|
||||
| 1 | Monique | Davis | Monique Davis |
|
||||
| 2 | Teri | Gutierrez | Teri Gutierrez |
|
||||
| 3 | Spencer | Pautier | Spencer Pautier |
|
||||
| 4 | Louis | Ramsey | Louis Ramsey |
|
||||
| 5 | Alvin | Greene | Alvin Greene |
|
||||
| 6 | Sophie | Freeman | Sophie Freeman |
|
||||
| 7 | Edgar Frank "Ted" | Codd | Edgar Frank "Ted" Codd |
|
||||
| 8 | Donald D. | Chamberlin | Donald D. Chamberlin |
|
||||
| 9 | Raymond F. | Boyce | Raymond F. Boyce |
|
||||
+-----------+-------------------+------------+------------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+-------------------+------------+------------------------+
|
||||
| studentID | FirstName | LastName | FullName |
|
||||
+-----------+-------------------+------------+------------------------+
|
||||
| 1 | Monique | Davis | Monique Davis |
|
||||
| 2 | Teri | Gutierrez | Teri Gutierrez |
|
||||
| 3 | Spencer | Pautier | Spencer Pautier |
|
||||
| 4 | Louis | Ramsey | Louis Ramsey |
|
||||
| 5 | Alvin | Greene | Alvin Greene |
|
||||
| 6 | Sophie | Freeman | Sophie Freeman |
|
||||
| 7 | Edgar Frank "Ted" | Codd | Edgar Frank "Ted" Codd |
|
||||
| 8 | Donald D. | Chamberlin | Donald D. Chamberlin |
|
||||
| 9 | Raymond F. | Boyce | Raymond F. Boyce |
|
||||
+-----------+-------------------+------------+------------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
\* كما هو الحال مع جميع هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي.
|
||||
|
||||
|
@ -16,27 +16,29 @@ localeTitle: دالة Sum Sum
|
||||
|
||||
إن ترتيب مجموعة البيانات هذه في ترتيب تنازلي (DESC) يضع المرشحين الذين لديهم أكبر مساهمات إجمالية في أعلى القائمة.
|
||||
|
||||
`SELECT Candidate, Election_year, sum(Total_$), count(*)
|
||||
FROM combined_party_data
|
||||
WHERE Election_year = 2016
|
||||
GROUP BY Candidate, Election_year -- this tells the DBMS to summarize by these two columns
|
||||
HAVING sum(Total_$) > 20000000 -- limits the rows presented from the summary of money ($20 Million USD)
|
||||
ORDER BY sum(Total_$) DESC; -- orders the presented rows with the largest ones first.
|
||||
`
|
||||
```sql
|
||||
SELECT Candidate, Election_year, sum(Total_$), count(*)
|
||||
FROM combined_party_data
|
||||
WHERE Election_year = 2016
|
||||
GROUP BY Candidate, Election_year -- this tells the DBMS to summarize by these two columns
|
||||
HAVING sum(Total_$) > 20000000 -- limits the rows presented from the summary of money ($20 Million USD)
|
||||
ORDER BY sum(Total_$) DESC; -- orders the presented rows with the largest ones first.
|
||||
```
|
||||
|
||||
`+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| Candidate | Election_year | sum(Total_$) | count(*) |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| CLINTON, HILLARY RODHAM & KAINE, TIMOTHY M (TIM) | 2016 | 568135094.4400003 | 126 |
|
||||
| TRUMP, DONALD J & PENCE, MICHAEL R (MIKE) | 2016 | 366853142.7899999 | 114 |
|
||||
| SANDERS, BERNARD (BERNIE) | 2016 | 258562022.17 | 122 |
|
||||
| CRUZ, RAFAEL EDWARD (TED) | 2016 | 93430700.29000005 | 104 |
|
||||
| CARSON, BENJAMIN S (BEN) | 2016 | 62202411.12999996 | 93 |
|
||||
| RUBIO, MARCO ANTONIO | 2016 | 44384313.9 | 106 |
|
||||
| BUSH, JOHN ELLIS (JEB) | 2016 | 34606731.78 | 97 |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
7 rows in set (0.01 sec)
|
||||
`
|
||||
```text
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| Candidate | Election_year | sum(Total_$) | count(*) |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
| CLINTON, HILLARY RODHAM & KAINE, TIMOTHY M (TIM) | 2016 | 568135094.4400003 | 126 |
|
||||
| TRUMP, DONALD J & PENCE, MICHAEL R (MIKE) | 2016 | 366853142.7899999 | 114 |
|
||||
| SANDERS, BERNARD (BERNIE) | 2016 | 258562022.17 | 122 |
|
||||
| CRUZ, RAFAEL EDWARD (TED) | 2016 | 93430700.29000005 | 104 |
|
||||
| CARSON, BENJAMIN S (BEN) | 2016 | 62202411.12999996 | 93 |
|
||||
| RUBIO, MARCO ANTONIO | 2016 | 44384313.9 | 106 |
|
||||
| BUSH, JOHN ELLIS (JEB) | 2016 | 34606731.78 | 97 |
|
||||
+--------------------------------------------------+---------------+-------------------+----------+
|
||||
7 rows in set (0.01 sec)
|
||||
```
|
||||
|
||||
كما هو الحال مع كل هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي.
|
||||
|
||||
|
@ -22,8 +22,9 @@ localeTitle: بناء جملة SQL
|
||||
|
||||
يتم استخدام هذا لتحديد قاعدة البيانات التي تحتوي على جداول عبارات SQL الخاصة بك:
|
||||
|
||||
`use fcc_sql_guides_database; -- select the guide sample database
|
||||
`
|
||||
```sql
|
||||
use fcc_sql_guides_database; -- select the guide sample database
|
||||
```
|
||||
|
||||
### اختر من جمل
|
||||
|
||||
|
@ -16,21 +16,23 @@ localeTitle: مشغل اتحاد SQL
|
||||
|
||||
بيان SQL
|
||||
|
||||
`SELECT 'aaaaa'
|
||||
UNION
|
||||
SELECT 'bbbbbbbbb';
|
||||
`
|
||||
```sql
|
||||
SELECT 'aaaaa'
|
||||
UNION
|
||||
SELECT 'bbbbbbbbb';
|
||||
```
|
||||
|
||||
انتاج |
|
||||
|
||||
`+-----------+
|
||||
| aaaaa |
|
||||
+-----------+
|
||||
| aaaaa |
|
||||
| bbbbbbbbb |
|
||||
+-----------+
|
||||
2 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+
|
||||
| aaaaa |
|
||||
+-----------+
|
||||
| aaaaa |
|
||||
| bbbbbbbbb |
|
||||
+-----------+
|
||||
2 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
### مثال باستخدام جداول الطلاب
|
||||
|
||||
@ -45,15 +47,16 @@ localeTitle: مشغل اتحاد SQL
|
||||
|
||||
\`\` \`النص + ----------- + -------------------------------- + | StudentID | FullName | + ----------- + -------------------------------- + | 1 | مونيك ديفيز | 2 | تيري جوتيريز | | 3 | سبنسر باوتير | | 4 | لويس رمزي | 5 | ألفين غرين | | 7 | Maximo.Smith@freeCodeCamp.org | | 8 | Michael.Roach@freeCodeCamp.ort | + ----------- + -------------------------------- + 7 صفوف في مجموعة (0.00 ثانية)
|
||||
|
||||
`## SQL UNION ALL Operator
|
||||
|
||||
The UNION ALL operator is an extension to UNION operator where it should result you a A+B of rows in the ouptput assuming A and B is your input, in simple terms UNION ALL doesn't deduplicate.
|
||||
|
||||
|
||||
### Basic Syntax
|
||||
|
||||
SQL Statement
|
||||
`
|
||||
```
|
||||
## SQL UNION ALL Operator
|
||||
|
||||
The UNION ALL operator is an extension to UNION operator where it should result you a A+B of rows in the ouptput assuming A and B is your input, in simple terms UNION ALL doesn't deduplicate.
|
||||
|
||||
|
||||
### Basic Syntax
|
||||
|
||||
SQL Statement
|
||||
```
|
||||
|
||||
مزود SELECT expression1، expression2،… expression _n من الجداول \[حيث الظروف\] الاتحاد كله SELECT expression1، expression2،… expression_ n من الجداول \[حيث الظروف\] ؛ \`\` \`
|
||||
|
||||
|
@ -18,24 +18,26 @@ localeTitle: استعلام تحديث SQL
|
||||
|
||||
هذا هو جدول الطلاب ونحن نبدأ هذه العملية
|
||||
|
||||
`SELECT * FROM student;
|
||||
`
|
||||
```sql
|
||||
SELECT * FROM student;
|
||||
```
|
||||
|
||||
`+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
| studentID | FullName | sat_score | programOfStudy | rcd_Created | rcd_Updated |
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
| 1 | Monique Davis | 400 | Literature | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
| studentID | FullName | sat_score | programOfStudy | rcd_Created | rcd_Updated |
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
| 1 | Monique Davis | 400 | Literature | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
### تغيير الجدول وإضافة حقل جديد
|
||||
|
||||
@ -45,45 +47,48 @@ localeTitle: استعلام تحديث SQL
|
||||
|
||||
يتم تنفيذ جدول الطالب بعد التعديل.
|
||||
|
||||
`mysql> SELECT FullName, sat_score, programOfStudy, schoolEmailAdr FROM student;
|
||||
+------------------------+-----------+------------------+----------------+
|
||||
| FullName | sat_score | programOfStudy | schoolEmailAdr |
|
||||
+------------------------+-----------+------------------+----------------+
|
||||
| Monique Davis | 400 | Literature | NULL |
|
||||
| Teri Gutierrez | 800 | Programming | NULL |
|
||||
| Spencer Pautier | 1000 | Programming | NULL |
|
||||
| Louis Ramsey | 1200 | Programming | NULL |
|
||||
| Alvin Greene | 1200 | Programming | NULL |
|
||||
| Sophie Freeman | 1200 | Programming | NULL |
|
||||
| Edgar Frank "Ted" Codd | 2400 | Computer Science | NULL |
|
||||
| Donald D. Chamberlin | 2400 | Computer Science | NULL |
|
||||
| Raymond F. Boyce | 2400 | Computer Science | NULL |
|
||||
+------------------------+-----------+------------------+----------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
mysql> SELECT FullName, sat_score, programOfStudy, schoolEmailAdr FROM student;
|
||||
+------------------------+-----------+------------------+----------------+
|
||||
| FullName | sat_score | programOfStudy | schoolEmailAdr |
|
||||
+------------------------+-----------+------------------+----------------+
|
||||
| Monique Davis | 400 | Literature | NULL |
|
||||
| Teri Gutierrez | 800 | Programming | NULL |
|
||||
| Spencer Pautier | 1000 | Programming | NULL |
|
||||
| Louis Ramsey | 1200 | Programming | NULL |
|
||||
| Alvin Greene | 1200 | Programming | NULL |
|
||||
| Sophie Freeman | 1200 | Programming | NULL |
|
||||
| Edgar Frank "Ted" Codd | 2400 | Computer Science | NULL |
|
||||
| Donald D. Chamberlin | 2400 | Computer Science | NULL |
|
||||
| Raymond F. Boyce | 2400 | Computer Science | NULL |
|
||||
+------------------------+-----------+------------------+----------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
### اختبار المنطق (خطوة مهمة جدا!)
|
||||
|
||||
`SELECT FullName, instr(FullName," ") AS firstSpacePosition,
|
||||
concat(substring(FullName,1,instr(FullName," ")-1),"@someSchool.edu") AS schoolEmail
|
||||
FROM student;
|
||||
`
|
||||
```sql
|
||||
SELECT FullName, instr(FullName," ") AS firstSpacePosition,
|
||||
concat(substring(FullName,1,instr(FullName," ")-1),"@someSchool.edu") AS schoolEmail
|
||||
FROM student;
|
||||
```
|
||||
|
||||
`+------------------------+--------------------+------------------------+
|
||||
| FullName | firstSpacePosition | schoolEmail |
|
||||
+------------------------+--------------------+------------------------+
|
||||
| Monique Davis | 8 | Monique@someSchool.edu |
|
||||
| Teri Gutierrez | 5 | Teri@someSchool.edu |
|
||||
| Spencer Pautier | 8 | Spencer@someSchool.edu |
|
||||
| Louis Ramsey | 6 | Louis@someSchool.edu |
|
||||
| Alvin Greene | 6 | Alvin@someSchool.edu |
|
||||
| Sophie Freeman | 7 | Sophie@someSchool.edu |
|
||||
| Edgar Frank "Ted" Codd | 6 | Edgar@someSchool.edu |
|
||||
| Donald D. Chamberlin | 7 | Donald@someSchool.edu |
|
||||
| Raymond F. Boyce | 8 | Raymond@someSchool.edu |
|
||||
+------------------------+--------------------+------------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+------------------------+--------------------+------------------------+
|
||||
| FullName | firstSpacePosition | schoolEmail |
|
||||
+------------------------+--------------------+------------------------+
|
||||
| Monique Davis | 8 | Monique@someSchool.edu |
|
||||
| Teri Gutierrez | 5 | Teri@someSchool.edu |
|
||||
| Spencer Pautier | 8 | Spencer@someSchool.edu |
|
||||
| Louis Ramsey | 6 | Louis@someSchool.edu |
|
||||
| Alvin Greene | 6 | Alvin@someSchool.edu |
|
||||
| Sophie Freeman | 7 | Sophie@someSchool.edu |
|
||||
| Edgar Frank "Ted" Codd | 6 | Edgar@someSchool.edu |
|
||||
| Donald D. Chamberlin | 7 | Donald@someSchool.edu |
|
||||
| Raymond F. Boyce | 8 | Raymond@someSchool.edu |
|
||||
+------------------------+--------------------+------------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
_ملاحظة حول concat (): في MySQL يتم استخدام هذا الأمر في سلاسل مدمجة ، وليس كذلك في إصدارات SQL الأخرى (راجع الدليل). في هذا الاستخدام يعمل مثل هذا: يتم دمج السلسلة الفرعية للحقل FullName مع عدم تضمين المساحة الأولى مع "@ someSchool.edu". في العالم الحقيقي سيكون هذا أكثر تعقيدًا وستحتاج إلى التأكد من أن عنوان البريد الإلكتروني فريد من نوعه._
|
||||
|
||||
@ -91,28 +96,30 @@ _ملاحظة حول concat (): في MySQL يتم استخدام هذا الأم
|
||||
|
||||
سنتظاهر بأن هذا ما نريده ونحدّث الجدول بهذه المعلومات:
|
||||
|
||||
`UPDATE student SET schoolEmailAdr = concat(substring(FullName,1,instr(FullName," ")-1),"@someSchool.edu")
|
||||
WHERE schoolEmailAdr is NULL;
|
||||
`
|
||||
```sql
|
||||
UPDATE student SET schoolEmailAdr = concat(substring(FullName,1,instr(FullName," ")-1),"@someSchool.edu")
|
||||
WHERE schoolEmailAdr is NULL;
|
||||
```
|
||||
|
||||
نجاح!
|
||||
|
||||
`mysql> SELECT FullName, sat_score, programOfStudy, schoolEmailAdr FROM student;
|
||||
+------------------------+-----------+------------------+------------------------+
|
||||
| FullName | sat_score | programOfStudy | schoolEmailAdr |
|
||||
+------------------------+-----------+------------------+------------------------+
|
||||
| Monique Davis | 400 | Literature | Monique@someSchool.edu |
|
||||
| Teri Gutierrez | 800 | Programming | Teri@someSchool.edu |
|
||||
| Spencer Pautier | 1000 | Programming | Spencer@someSchool.edu |
|
||||
| Louis Ramsey | 1200 | Programming | Louis@someSchool.edu |
|
||||
| Alvin Greene | 1200 | Programming | Alvin@someSchool.edu |
|
||||
| Sophie Freeman | 1200 | Programming | Sophie@someSchool.edu |
|
||||
| Edgar Frank "Ted" Codd | 2400 | Computer Science | Edgar@someSchool.edu |
|
||||
| Donald D. Chamberlin | 2400 | Computer Science | Donald@someSchool.edu |
|
||||
| Raymond F. Boyce | 2400 | Computer Science | Raymond@someSchool.edu |
|
||||
+------------------------+-----------+------------------+------------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
mysql> SELECT FullName, sat_score, programOfStudy, schoolEmailAdr FROM student;
|
||||
+------------------------+-----------+------------------+------------------------+
|
||||
| FullName | sat_score | programOfStudy | schoolEmailAdr |
|
||||
+------------------------+-----------+------------------+------------------------+
|
||||
| Monique Davis | 400 | Literature | Monique@someSchool.edu |
|
||||
| Teri Gutierrez | 800 | Programming | Teri@someSchool.edu |
|
||||
| Spencer Pautier | 1000 | Programming | Spencer@someSchool.edu |
|
||||
| Louis Ramsey | 1200 | Programming | Louis@someSchool.edu |
|
||||
| Alvin Greene | 1200 | Programming | Alvin@someSchool.edu |
|
||||
| Sophie Freeman | 1200 | Programming | Sophie@someSchool.edu |
|
||||
| Edgar Frank "Ted" Codd | 2400 | Computer Science | Edgar@someSchool.edu |
|
||||
| Donald D. Chamberlin | 2400 | Computer Science | Donald@someSchool.edu |
|
||||
| Raymond F. Boyce | 2400 | Computer Science | Raymond@someSchool.edu |
|
||||
+------------------------+-----------+------------------+------------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
كما هو الحال مع كل هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي.
|
||||
|
||||
|
@ -8,32 +8,36 @@ localeTitle: SQL Update Statement
|
||||
|
||||
كن حذرا. يمكنك تحديث جميع سجلات الجدول أو عدد قليل فقط. استخدم شرط `WHERE` لتحديد السجلات التي تريد تحديثها. من الممكن تحديث عمود واحد أو أكثر في كل مرة. الصيغة هي:
|
||||
|
||||
`UPDATE table_name
|
||||
SET column1 = value1,
|
||||
column2 = value2, ...
|
||||
WHERE condition;
|
||||
`
|
||||
```sql
|
||||
UPDATE table_name
|
||||
SET column1 = value1,
|
||||
column2 = value2, ...
|
||||
WHERE condition;
|
||||
```
|
||||
|
||||
في ما يلي مثال على تحديث اسم السجل الذي يحمل الرقم التعريفي 4:
|
||||
|
||||
`UPDATE Person
|
||||
SET Name = “Elton John”
|
||||
WHERE Id = 4;
|
||||
`
|
||||
```sql
|
||||
UPDATE Person
|
||||
SET Name = “Elton John”
|
||||
WHERE Id = 4;
|
||||
```
|
||||
|
||||
يمكنك أيضًا تحديث الأعمدة في جدول باستخدام القيم من الجداول الأخرى. استخدم جملة `JOIN` للحصول على البيانات من جداول متعددة. الصيغة هي:
|
||||
|
||||
`UPDATE table_name1
|
||||
SET table_name1.column1 = table_name2.columnA
|
||||
table_name1.column2 = table_name2.columnB
|
||||
FROM table_name1
|
||||
JOIN table_name2 ON table_name1.ForeignKey = table_name2.Key
|
||||
`
|
||||
```sql
|
||||
UPDATE table_name1
|
||||
SET table_name1.column1 = table_name2.columnA
|
||||
table_name1.column2 = table_name2.columnB
|
||||
FROM table_name1
|
||||
JOIN table_name2 ON table_name1.ForeignKey = table_name2.Key
|
||||
```
|
||||
|
||||
في ما يلي مثال على تحديث مدير جميع السجلات:
|
||||
|
||||
`UPDATE Person
|
||||
SET Person.Manager = Department.Manager
|
||||
FROM Person
|
||||
JOIN Department ON Person.DepartmentID = Department.ID
|
||||
`
|
||||
```sql
|
||||
UPDATE Person
|
||||
SET Person.Manager = Department.Manager
|
||||
FROM Person
|
||||
JOIN Department ON Person.DepartmentID = Department.ID
|
||||
```
|
@ -12,24 +12,26 @@ localeTitle: SQL حيث البند
|
||||
|
||||
في ما يلي قائمة الطلاب الكاملة الحالية لمقارنة مجموعة نتائج `WHERE` :
|
||||
|
||||
`select studentID, FullName, sat_score, rcd_updated from student;
|
||||
`
|
||||
```sql
|
||||
select studentID, FullName, sat_score, rcd_updated from student;
|
||||
```
|
||||
|
||||
`+-----------+------------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 3 | Spencer Pautier | 1000 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 6 | Sophie Freeman | 1200 | 2017-08-16 15:34:50 |
|
||||
| 7 | Edgar Frank "Ted" Codd | 2400 | 2017-08-16 15:35:33 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
| 9 | Raymond F. Boyce | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+------------------------+-----------+---------------------+
|
||||
9 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
سيتم تقديم الصفوف التي ...
|
||||
|
||||
@ -38,24 +40,26 @@ localeTitle: SQL حيث البند
|
||||
|
||||
في ما يلي طلب بحث محدّث ، حيث لن يتم عرض أي سجل يحتوي على درجة SAT في هذه القائمة (1000 ، 1400):
|
||||
|
||||
`select studentID, FullName, sat_score, recordUpdated
|
||||
from student
|
||||
where (studentID between 1 and 5 or studentID = 8)
|
||||
and
|
||||
sat_score NOT in (1000, 1400);
|
||||
`
|
||||
```sql
|
||||
select studentID, FullName, sat_score, recordUpdated
|
||||
from student
|
||||
where (studentID between 1 and 5 or studentID = 8)
|
||||
and
|
||||
sat_score NOT in (1000, 1400);
|
||||
```
|
||||
|
||||
`+-----------+----------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
5 rows in set (0.00 sec)
|
||||
`
|
||||
```text
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
| studentID | FullName | sat_score | rcd_updated |
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 |
|
||||
| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 |
|
||||
| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 |
|
||||
| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 |
|
||||
| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 |
|
||||
+-----------+----------------------+-----------+---------------------+
|
||||
5 rows in set (0.00 sec)
|
||||
```
|
||||
|
||||
\* كما هو الحال مع جميع هذه الأشياء SQL هناك أكثر من ذلك بكثير من ما هو موجود في هذا الدليل التمهيدي.
|
||||
|
||||
|
@ -24,25 +24,28 @@ localeTitle: إدارة عدة مفاتيح SSH
|
||||
|
||||
لبدء عملك ، عليك استنساخ مستودع git باستخدام SSH:
|
||||
|
||||
`git clone git@github.com:steve/raspberry-spy.git
|
||||
`
|
||||
```bash
|
||||
git clone git@github.com:steve/raspberry-spy.git
|
||||
```
|
||||
|
||||
في هذه اللحظة ، سيكون GitHub مثل: "Yo ، هذا مستودع خاص! نحن بحاجة إلى تشفير حركة المرور باستخدام هذا المفتاح العام الذي أمتلكه هنا ومفتاحك الخاص"
|
||||
|
||||
لقد قمت بإضافة المفتاح العام إلى ملف التعريف الخاص بك على GitHub ، ولكن SSH لديه بطريقة أو بأخرى معرفة أين يوجد المفتاح الخاص المقابل الخاص بك. نظرًا لأننا لا نملك أي فكرة عن المفتاح الخاص الذي يجب استخدامه عند استخدام SSH في `git@github.com` ، يحاول عميل SSH العثور على مفتاح في الموقع الافتراضي ، وهو `~/.ssh/id_rsa` - إنه أفضل تخمين له. إذا لم يكن هناك ملف في هذا الموقع ، فستتلقى خطأً:
|
||||
|
||||
`Cloning into 'raspberry-spy'...
|
||||
Permission denied (publickey).
|
||||
fatal: Could not read from remote repository.
|
||||
|
||||
Please make sure you have the correct access rights
|
||||
and the repository exists.
|
||||
`
|
||||
```bash
|
||||
Cloning into 'raspberry-spy'...
|
||||
Permission denied (publickey).
|
||||
fatal: Could not read from remote repository.
|
||||
|
||||
Please make sure you have the correct access rights
|
||||
and the repository exists.
|
||||
```
|
||||
|
||||
إذا كان لديك _بعض_ المفاتيح الخاصة المخزنة في الملف `~/.ssh/id_rsa` ، `~/.ssh/id_rsa` عميل SSH هذا المفتاح الخاص لتشفير الاتصالات. إذا كان هذا المفتاح مرتبطًا بكلمة مرور (كما ينبغي أن يكون) ، فستتم مطالبتك بكلمة مرور ، مثل:
|
||||
|
||||
`Enter passphrase for key '/Users/steve/.ssh/id_rsa':
|
||||
`
|
||||
```bash
|
||||
Enter passphrase for key '/Users/steve/.ssh/id_rsa':
|
||||
```
|
||||
|
||||
إذا أدخلت عبارة المرور الصحيحة وإذا كان هذا المفتاح الخاص هو بالفعل المفتاح الذي يتوافق مع المفتاح العام الذي أرفقته بملفك الشخصي ، فسيتم سداد كل شيء بشكل جيد وسيتم استنساخ المستودع بنجاح.
|
||||
|
||||
@ -50,8 +53,9 @@ localeTitle: إدارة عدة مفاتيح SSH
|
||||
|
||||
إذا كنت تريد استخدام مفتاح خاص سميته بشكل مختلف ، فيجب عليك إضافته يدويًا:
|
||||
|
||||
`ssh-add ~/.ssh/_id_rsa
|
||||
`
|
||||
```bash
|
||||
ssh-add ~/.ssh/_id_rsa
|
||||
```
|
||||
|
||||
بعد إدخال عبارة المرور ، يمكنك التحقق مما إذا كان المفتاح قد تمت إضافته إلى `ssh-agent` (عميل SSH) عن طريق تنفيذ `ssh-add -l` . يقوم هذا الأمر بإدراج جميع المفاتيح المتوفرة حاليًا لعميل SSH.
|
||||
|
||||
@ -77,21 +81,23 @@ localeTitle: إدارة عدة مفاتيح SSH
|
||||
|
||||
أول شيء سنقوم بحله باستخدام ملف `config` هذا هو تجنب الاضطرار إلى إضافة مفاتيح SSH ذات اسم مخصص باستخدام `ssh-add` . بفرض افتراض أن مفتاح SSH الخاص بك هو `~/.ssh/_id_rsa` ، أضف المتابعة إلى ملف `config` :
|
||||
|
||||
`Host github.com
|
||||
HostName github.com
|
||||
User git
|
||||
IdentityFile ~/.ssh/_id_rsa
|
||||
IdentitiesOnly yes
|
||||
`
|
||||
```bash
|
||||
Host github.com
|
||||
HostName github.com
|
||||
User git
|
||||
IdentityFile ~/.ssh/_id_rsa
|
||||
IdentitiesOnly yes
|
||||
```
|
||||
|
||||
الآن تأكد من أن `~/.ssh/_id_rsa` ليس في `ssh-agent` بتنفيذ `ssh-add -D` . سيؤدي هذا الأمر إلى إزالة كافة المفاتيح من جلسة عمل `ssh-agent` النشطة حاليًا. يتم إعادة ضبط الجلسة في كل مرة تقوم فيها بتسجيل الخروج أو إعادة التشغيل (أو إذا قمت بقتل عملية `ssh-agent` يدوياً). يمكننا "محاكاة" إعادة التشغيل عن طريق تنفيذ الأمر المذكور.
|
||||
|
||||
إذا حاولت استنساخ مستودع GitHub الخاص بك الآن ، فسيكون ذلك كما لو قمنا بإضافة المفتاح يدويًا (كما فعلنا من قبل). سيُطلب منك كلمة المرور:
|
||||
|
||||
`git clone git@github.com:steve/raspberry-spy.git
|
||||
Cloning into 'raspberry-spy'...
|
||||
Enter passphrase for key '/Users/steve/.ssh/_id_rsa':
|
||||
`
|
||||
```bash
|
||||
git clone git@github.com:steve/raspberry-spy.git
|
||||
Cloning into 'raspberry-spy'...
|
||||
Enter passphrase for key '/Users/steve/.ssh/_id_rsa':
|
||||
```
|
||||
|
||||
ستلاحظ أن المفتاح الذي نطالب بكلمة المرور الخاصة به هو نفس المفتاح الذي حددناه في ملف `config` بنا. بعد إدخال كلمة مرور مفتاح SSH الصحيحة ، سيتم استنساخ المستودع بنجاح.
|
||||
|
||||
@ -101,32 +107,35 @@ localeTitle: إدارة عدة مفاتيح SSH
|
||||
|
||||
هذا يفتح البوابات. عندما تقوم بإعادة هذا ، فإن ذهنك يتسابق ويفكر في كيفية انتهاء كل مشاكلك مع مفاتيح SSH. فيما يلي بعض أمثلة التكوين المفيدة:
|
||||
|
||||
`Host bitbucket-corporate
|
||||
HostName bitbucket.org
|
||||
User git
|
||||
IdentityFile ~/.ssh/id_rsa_corp
|
||||
IdentitiesOnly yes
|
||||
`
|
||||
```bash
|
||||
Host bitbucket-corporate
|
||||
HostName bitbucket.org
|
||||
User git
|
||||
IdentityFile ~/.ssh/id_rsa_corp
|
||||
IdentitiesOnly yes
|
||||
```
|
||||
|
||||
الآن يمكنك استخدام `git clone git@bitbucket-corporate:company/project.git`
|
||||
|
||||
`Host bitbucket-personal
|
||||
HostName bitbucket.org
|
||||
User git
|
||||
IdentityFile ~/.ssh/id_rsa_personal
|
||||
IdentitiesOnly yes
|
||||
`
|
||||
```bash
|
||||
Host bitbucket-personal
|
||||
HostName bitbucket.org
|
||||
User git
|
||||
IdentityFile ~/.ssh/id_rsa_personal
|
||||
IdentitiesOnly yes
|
||||
```
|
||||
|
||||
الآن يمكنك استخدام `git clone git@bitbucket-personal:steve/other-pi-project.git`
|
||||
|
||||
`Host myserver
|
||||
HostName ssh.steve.com
|
||||
Port 1111
|
||||
IdentityFile ~/.ssh/id_rsa_personal
|
||||
IdentitiesOnly yes
|
||||
User steve
|
||||
IdentitiesOnly yes
|
||||
`
|
||||
```
|
||||
Host myserver
|
||||
HostName ssh.steve.com
|
||||
Port 1111
|
||||
IdentityFile ~/.ssh/id_rsa_personal
|
||||
IdentitiesOnly yes
|
||||
User steve
|
||||
IdentitiesOnly yes
|
||||
```
|
||||
|
||||
الآن يمكنك SSH في الخادم الخاص بك باستخدام `ssh myserver` . كم ذلك رائع؟ لا تحتاج إلى إدخال المنفذ واسم المستخدم يدويًا في كل مرة تقوم فيها بتنفيذ الأمر `ssh` .
|
||||
|
||||
@ -134,14 +143,16 @@ localeTitle: إدارة عدة مفاتيح SSH
|
||||
|
||||
يمكنك أيضًا تحديد المفتاح المحدد الذي يجب استخدامه لمخزون معين ، وتجاوز أي شيء في `config` SSH. يمكن تحديد أمر SSH محدد عن طريق تعيين `sshCommand` تحت `core` في `<project>/.git/config` . مثال:
|
||||
|
||||
`[core]
|
||||
sshCommand = ssh -i ~/.ssh/id_rsa_corp
|
||||
`
|
||||
```bash
|
||||
[core]
|
||||
sshCommand = ssh -i ~/.ssh/id_rsa_corp
|
||||
```
|
||||
|
||||
هذا ممكن مع git 2.10 أو في وقت لاحق. يمكنك أيضًا استخدام هذا الأمر لتجنب تعديل الملف يدويًا:
|
||||
|
||||
`git config core.sshCommand 'ssh -i ~/.ssh/id_rsa_corp'
|
||||
`
|
||||
```bash
|
||||
git config core.sshCommand 'ssh -i ~/.ssh/id_rsa_corp'
|
||||
```
|
||||
|
||||
### إدارة كلمة المرور
|
||||
|
||||
@ -149,8 +160,9 @@ localeTitle: إدارة عدة مفاتيح SSH
|
||||
|
||||
ابدأ بإضافة مفتاحك إلى keychain عبر تمرير الخيار `-K` إلى الأمر `ssh-add` :
|
||||
|
||||
`ssh-add -K ~/.ssh/id_rsa_whatever
|
||||
`
|
||||
```bash
|
||||
ssh-add -K ~/.ssh/id_rsa_whatever
|
||||
```
|
||||
|
||||
يمكنك الآن رؤية مفتاح SSH في keychain. على MacOS ، يبدو الأمر كالتالي: 
|
||||
|
||||
@ -158,10 +170,11 @@ localeTitle: إدارة عدة مفاتيح SSH
|
||||
|
||||
اتضح أن هناك طارة واحدة أكثر من القفز. افتح ملف SSH `config` الخاص بك وقم بإضافة ما يلي:
|
||||
|
||||
`Host *
|
||||
AddKeysToAgent yes
|
||||
UseKeychain yes
|
||||
`
|
||||
```bash
|
||||
Host *
|
||||
AddKeysToAgent yes
|
||||
UseKeychain yes
|
||||
```
|
||||
|
||||
الآن ، سوف تبحث SSH عن المفتاح في keychain وإذا وجدت أنه لن تتم مطالبتك بكلمة المرور. مفتاح سيضاف أيضا إلى `ssh-agent` . على MacOS ، سيعمل هذا على MacOS Sierra 10.12.2 أو ما بعده. في Linux ، يمكنك استخدام شيء ما مثل `gnome-keyring` وقد يعمل حتى بدون إجراء هذا التعديل الأخير على `config` SSH. أما بالنسبة لنظام التشغيل Windows - من يدري ، أليس كذلك؟
|
||||
|
||||
|
@ -10,10 +10,11 @@ SVG أو Scalable Vector Graphics هو معيار ويب لتعريف الرسو
|
||||
|
||||
يبدأ المطوّرون رسم SVG باستخدام العلامة `<svg>` ومساحة اسم XML كما يلي:
|
||||
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
|
||||
</svg>
|
||||
`
|
||||
```svg
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
|
||||
</svg>
|
||||
```
|
||||
|
||||
يتضمن النموذج أيضًا سمة `version` . سمة `version` اختيارية ولكن يُنصح باستخدامها مع مواصفات XML.
|
||||
|
||||
@ -67,16 +68,17 @@ SVG أو Scalable Vector Graphics هو معيار ويب لتعريف الرسو
|
||||
|
||||
جزء.
|
||||
|
||||
`<p > Before canvas . </p >
|
||||
< canvas width ="120" height ="60" > </ canvas >
|
||||
<p > After canvas . </p >
|
||||
< script >
|
||||
var canvas = document . querySelector (" canvas ") ;
|
||||
var context = canvas . getContext ("2 d ") ;
|
||||
context . fillStyle = " red ";
|
||||
context . fillRect (10 , 10 , 100 , 50) ;
|
||||
</ script >
|
||||
`
|
||||
```
|
||||
<p > Before canvas . </p >
|
||||
< canvas width ="120" height ="60" > </ canvas >
|
||||
<p > After canvas . </p >
|
||||
< script >
|
||||
var canvas = document . querySelector (" canvas ") ;
|
||||
var context = canvas . getContext ("2 d ") ;
|
||||
context . fillStyle = " red ";
|
||||
context . fillRect (10 , 10 , 100 , 50) ;
|
||||
</ script >
|
||||
```
|
||||
|
||||

|
||||
|
||||
@ -86,40 +88,42 @@ SVG أو Scalable Vector Graphics هو معيار ويب لتعريف الرسو
|
||||
|
||||
يحتوي متغير النتائج على مصفوفة من الكائنات التي تمثل ردود المسح.
|
||||
|
||||
`var results = [
|
||||
{ name : " Satisfied " , count : 1043 , color : " lightblue "} ,
|
||||
{ name : " Neutral " , count : 563 , color : " lightgreen "} ,
|
||||
{ name : " Unsatisfied " , count : 510 , color : " pink "} ,
|
||||
{ name : " No comment " , count : 175 , color : " silver "}
|
||||
];
|
||||
`
|
||||
```
|
||||
var results = [
|
||||
{ name : " Satisfied " , count : 1043 , color : " lightblue "} ,
|
||||
{ name : " Neutral " , count : 563 , color : " lightgreen "} ,
|
||||
{ name : " Unsatisfied " , count : 510 , color : " pink "} ,
|
||||
{ name : " No comment " , count : 175 , color : " silver "}
|
||||
];
|
||||
```
|
||||
|
||||
لرسم مخطط دائري ، نرسم عددًا من الشرائح الدائرية ، تتكون كل منها من قوس وزوج من الخطوط إلى مركز هذا القوس. يمكننا حساب الزاوية المأخوذة من كل قوس بقسمة دائرة كاملة (2 π) على العدد الإجمالي للاستجابات ثم ضرب ذلك العدد (زاوية لكل استجابة) بعدد الأشخاص الذين اختاروا اختيارًا معينًا.
|
||||
|
||||
`< canvas width ="200" height ="200" > </ canvas >
|
||||
< script >
|
||||
var cx = document . querySelector (" canvas ") . getContext ("2 d ") ;
|
||||
var total = results . reduce ( function ( sum , choice ) {
|
||||
return sum + choice . count ;
|
||||
} , 0) ;
|
||||
|
||||
// Start at the top
|
||||
|
||||
var currentAngle = -0.5 * Math . PI ;
|
||||
results . forEach ( function ( result ) {
|
||||
var sliceAngle = ( result . count / total ) * 2 * Math . PI ;
|
||||
cx . beginPath () ;
|
||||
// center =100 ,100 , radius =100
|
||||
// from current angle , clockwise by slice ' s angle
|
||||
cx . arc (100 , 100 , 100 ,
|
||||
currentAngle , currentAngle + sliceAngle );
|
||||
currentAngle += sliceAngle ;
|
||||
cx . lineTo (100 , 100) ;
|
||||
cx . fillStyle = result . color ;
|
||||
cx . fill () ;
|
||||
}) ;
|
||||
</ script >
|
||||
`
|
||||
```
|
||||
< canvas width ="200" height ="200" > </ canvas >
|
||||
< script >
|
||||
var cx = document . querySelector (" canvas ") . getContext ("2 d ") ;
|
||||
var total = results . reduce ( function ( sum , choice ) {
|
||||
return sum + choice . count ;
|
||||
} , 0) ;
|
||||
|
||||
// Start at the top
|
||||
|
||||
var currentAngle = -0.5 * Math . PI ;
|
||||
results . forEach ( function ( result ) {
|
||||
var sliceAngle = ( result . count / total ) * 2 * Math . PI ;
|
||||
cx . beginPath () ;
|
||||
// center =100 ,100 , radius =100
|
||||
// from current angle , clockwise by slice ' s angle
|
||||
cx . arc (100 , 100 , 100 ,
|
||||
currentAngle , currentAngle + sliceAngle );
|
||||
currentAngle += sliceAngle ;
|
||||
cx . lineTo (100 , 100) ;
|
||||
cx . fillStyle = result . color ;
|
||||
cx . fill () ;
|
||||
}) ;
|
||||
</ script >
|
||||
```
|
||||
|
||||
هذا يرسم المخطط التالي: 
|
||||
|
||||
|
Reference in New Issue
Block a user