SQL labتاقیگەی SQL
A real runs inside this page. Write a , press Run and see what it does: the it reads light up, the appears row by row, new rows slide in and deleted rows fade away.
ڕاستەقینەی لە ناو ئەم پەڕەیەدا کار دەکات. بنووسە، «جێبەجێکردن» دابگرە و ببینە چی دەکات: ئەو دەیانخوێنێتەوە ڕووناک دەبنەوە، ڕیز بە ڕیز دەردەکەوێت، نوێ دێنە ناوەوە و سڕاوە کاڵ دەبنەوە و دەڕۆن.
SQL codeکۆدی SQL
Ctrl + Enter also runs the code.Ctrl + Enter یش کۆدەکە جێبەجێ دەکات.
Tables in the databaseخشتەکانی بنکەدراوەکە
Starting the database…بنکەدراوەکە دەست پێدەکات…
Tables, rows and columnsخشتەکان، ڕیزەکان و ستوونەکان
A keeps its in . Each holds one kind of value (a name, a city, an age) and each is one thing: one student, one course. The id column is the : no two rows have the same id.
لە ناو هەڵدەگرێت. هەر یەک جۆر نرخ هەڵدەگرێت (ناو، شار، تەمەن) و هەر یەک شتە: یەک قوتابی، یەک کۆرس. id : هیچ دوو هەمان idیان نییە.
In enrollments, the columns student_id and course_id are : they point to rows of students and courses. That is how a JOIN finds which student took which course.
لە خشتەی enrollmentsـدا student_id و course_id : ئاماژە بە students و courses دەکەن. JOIN بەم شێوەیە دەزانێت کام قوتابی کام کۆرسی خوێندووە.
Four everyday statementsچوار فەرمانی ڕۆژانە
| Statement | What it doesچی دەکات |
|---|---|
SELECT | Reads rows. It never changes the table. دەخوێنێتەوە. هەرگیز ناگۆڕێت. |
INSERT | Adds new rows. زیاد دەکات. |
UPDATE | Changes values in existing rows. لە دەگۆڕێت. |
DELETE | Removes rows. دەسڕێتەوە. |
SQL inside real programsSQL لە ناو بەرنامەکانی ڕاستەقینەدا
In this lab you type SQL yourself. In a real website, never glue a user's words into an SQL string: an attacker could type SQL of their own (this is called SQL injection). Use prepared statements, which keep the code and the values apart. See database security in PHP.
لەم تاقیگەیەدا خۆت SQL دەنووسیت. لە ماڵپەڕێکی ڕاستەقینەدا هەرگیز قسەکانی بەکارهێنەر بە دەقی SQLـەوە مەلکێنە: هێرشبەرێک دەتوانێت SQLـی خۆی بنووسێت (ئەمە پێی دەوترێت SQL injection). prepared statement بەکاربهێنە کە کۆد و نرخەکان لە یەکتر جیا دەکاتەوە. سەیری ئاسایشی بنکەدراوە لە PHPـدا بکە.
Read more: databases and SQL, SELECT in depth, functions and grouping and SQLite basics.
زیاتر بخوێنەوە: بنکەدراوە و SQL، SELECT بە وردی، فەنکشن و کۆمەڵەکردن و بنەماکانی SQLite.