Easily Duplicate, Copy or Backup Tables in Oracle, PostgreSQL, DB2 and SQLite with Create Table As SQL بسهولة المكررة ، نسخ أو النسخ الاحتياطي الجداول في أوراكل ، بوستجرس ، DB2 وSQLite مع إنشاء الجدول كما مزود
In Oracle, PostgreSQL, DB2 and SQLite database system, there is a nice command feature called Create Table As which allows easy duplicating of a table with data from another or a few other tables. في أوراكل ، بوستجرس ، DB2 وSQLite نظام قاعدة البيانات ، هناك ميزة جميلة القيادة كما دعا إنشاء الجدول الذي يسمح من السهل تكرار البيانات من الجدول مع آخر أو عدد قليل من الجداول الأخرى. The SQL command can also be used to ‘copy and paste’ a table exactly or backup a table data before performing data manipulation query on the original table, just in case the script has error and the backup date can be used to restore to original state. Create Table As will creates a new table built from the content of dataset or result set retrieved by a Select SQL query from a table that already exists within the database. فإن مزود القيادة يمكن أن تستخدم أيضا ل'نسخ ولصق' أ الجدول تماما أو الاحتياطية جدول البيانات قبل أداء البيانات تلاعب استفسار عن الجدول الأصلي ، فقط في حالة والسيناريو قد النسخ الاحتياطي خطأ وحتى الآن يمكن أن تستخدم لاستعادة لالأصلية . إنشاء الجدول وكما سوف يخلق الجدول الجديد بنيت من محتوى البيانات أو نتيجة للاستخراج من جانب مجموعة مختارة مزود استفسار من أن الجدول موجود بالفعل داخل قاعدة البيانات.
The syntax of Create Table As SQL statement is: فإن تركيب من إنشاء الجدول كما هو مزود البيان :
CREATE TABLE table_name [ ( column_name [, ...] ) ] CREATE الجدول table_name [(column_name [،...])]
AS select [ * ! كما حدد [*! ( column_name [, ...] ) ] FROM source_table_name (column_name [،...])] من source_table_name
Replace table_name with the name of the new table that will be created. يستعاض عن table_name مع اسم الجدول الجديد الذي سيتم إنشاؤه. Column name is optional, where you can specify multiple columns by including their names in a comma-delimited list. اسم العمود هو اختياري ، حيث يمكنك تحديد أعمدة متعددة من قبل ، بما في ذلك أسماؤهم في وضع تخوم فاصلة بين قائمة. Else, the structure of the new table will be based on the column names, types and number of columns returned by the Select statement, together with the row data. آخر ، وهيكل الجدول الجديد سيكون على أساس عمود أسماء وأنواع وعدد من الأعمدة وعاد بها حدد البيان ، جنبا إلى جنب مع البيانات على التوالي. If you specify the column name, note that there should be the same number of columns specified as are returned by select. إذا كنت تحديد اسم العمود ، علما أنه ينبغي أن يكون هناك نفس العدد من الأعمدة المحددة كما هي عادت من جانب اختيار.
The select statement at the end of create table as command must be valid, and has the number of targets selected matching the number of columns in the optional column list preceding the AS clause. وقد حدد بيان في نهاية إنشاء الجدول كما يجب أن تكون صالحة للقيادة ، وعدد من الأهداف المختارة مطابقة عدد من الأعمدة في العمود اختياري قائمة السابقة كما شرط. It can be a complex select statement that retrieve data from multiple tables. ويمكن أن يكون اختيار مجمع البيان أن استرجاع البيانات من جداول متعددة. If optional column list is specified within parentheses, asterisk (*) can no longer be used in the select statement. وإذا كان اختياري هو العمود قائمة محددة داخل قوسين ، والنجمة (*) لم يعد من الممكن استخدامها في اختيار البيان.
For example, فعلى سبيل المثال ،
CREATE TABLE demo_backup CREATE الجدول demo_backup
AS SELECT * FROM demo; * المختارة من عرض ؛
Above SQL statement will create a exact replica backup table named demo_backup with data and structure (columns) of demo table. أعلاه مزود بيان سيخلق نسخة طبق الأصل احتياطية الجدول اسمه demo_backup مع البيانات والهيكل (الأعمدة) من عرض الجدول.
Possible error if you specify the optional column list is: ممكن خطأ إذا كنت تحدد اختياري قائمة العمود هو :
ERROR: CREATE TABLE/AS SELECT has mismatched column count خطأ : إنشاء الجدول وكما قد لا تتوافق اختر عدد الأعمدة
If you encounter this error message, this is due to optional list of columns in parentheses contains a different number of rows than the select statement returns. إذا واجهتك رسالة الخطأ هذه ، هذا ومن المقرر ان اختياري لقائمة من الأعمدة في بين قوسين يحتوي على عدد مختلف من الصفوف من اختيار بيان العودة. Double check if the number of columns specified is the same with the results that are expected from the select resultset. ضعف معرفة ما إذا كان عدد الأعمدة المحددة هو نفسه مع النتائج التي يتوقع من اختيار resultset.
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. هام : هذه هي آلة الصفحة المترجمة التي تقدم "كما هي" دون ضمان. Machine translation may be difficult to understand. الترجمة الآلية قد يكون من الصعب فهم. Please refer to يرجى الرجوع إلى original English article المادة الانكليزية الأصلية whenever possible. كلما كان ذلك ممكنا.
Share and contribute or get technical support and help at وحصة المساهمة أو الحصول على الدعم التقني والمساعدة في My Digital Life Forums بلادي الرقمي الحياة المنتديات .
Related Articles المواد ذات الصلة
- Create New Table by Selecting Data from Other Tables with CREATE TABLE AS إنشاء الجدول الجديد عن طريق اختيار البيانات من الجداول الأخرى مع خلق طاولة
- ORA-02449 Oracle Drop Table Error أورا - 02449 أوراكل إسقاط الجدول خطأ
- ORA-00942 Table or View Does Not Exist Oracle Error أورا - 00942 الجدول أو رأي لا وجود خطأ أوراكل
- Oracle ORA-14074 Create or Add New Partition Fails Error أوراكل أورا - 14074 إنشاء أو إضافة جديدة التقسيم فشل خطأ
- Create, Add or Split Oracle Database Partition Fails with ORA-14080 Error خلق ، وإضافة أو سبليت قاعدة البيانات أوراكل التقسيم فشل مع خطأ ORA - 14080
- Oracle ORA-01658 Unable to Create INITIAL Extent for Segment in Tablespace Error أوراكل ORA - 01658 تعذر إنشاء أولي لمدى في الجزء Tablespace خطأ
- Export, Backup or Copy Out the IE7 Search Providers List التصدير ، أو نسخة احتياطية تبين IE7 البحث قائمة مقدمي
- Duplicate File Hunter Free Registration Key by GAOTD ملف المكررة هنتر الحرة الرئيسية التسجيل عن طريق GAOTD
- Crack and Hack to Find, Reveal, Get, Recover and Retrieve All Windows Passwords with Ophcrack 2 and Rainbow Tables الكراك وابحث عن هاك ل، تكشف ، احصل على استرداد واسترجاع جميع كلمات السر ويندوز مع Ophcrack 2 والجداول قوس قزح
- How to Copy Encrypted or Copy-Protected DVD كيفية نسخ مشفر أو المحمية من النسخ دي في دي


























August 27th, 2008 22:01 أغسطس 27th ، 2008 22:01
Awesome dude!!…. المتأنق رهيبة!!.... helped me bigtime… simple and effective as it could be… Thanks ساعدني bigtime... بسيطة وفعالة لأنه يمكن أن يكون... شكرا
September 22nd, 2008 22:47 سبتمبر 22nd ، 2008 22:47
When doing this with PostgreSQL you will have to recreate the indexes from the original table manually. وعندما نفعل ذلك مع بوستجرس سيكون لكم لإعادة الأرقام القياسية من الجدول الأصلي يدويا. The copy command will not do this for you. نسخة القيادة لن تفعل ذلك عنك. Does anyone know of a way to do this automatically? يعرف أي شخص من طريقة للقيام بذلك تلقائيا؟