Thursday, June 5, 2014

CF

මේ මයික්‍රොකොන්ට්‍රෝලරය යනු මොකද්ද කියල?            ඇත්තටම මේක පෙනුමෙන් සංගෘහිත පරිපථයක්(Integrated Circuit (ic) ). ඒත් මේක පුංචි පරිගණකයක් වගේ.මේක අපිට ඕන විදියට දත්ත කවල අවශ්‍ය ආකාරයට යොදා ගන්න පුලුවන්.මෙයට පිටතින් දෙන්න ඕන ප්‍රදානයන්(Inputs) හා බල සැපයුම(Power supply) පමනයි. එවිට අප දී ඇති දත්ත වලට අනුව ක්‍රියා කරනවා.            මයික්‍රොකොන්ට්‍රෝලරය තුල RAM, ROM, Clock සියල්ල පිහිටවා ඇත. නමුත් මයික්‍රොප්‍රොසෙසරයට මේවා පිටතින් ලබා දිය යුතුයි.හැබැයි මයික්‍රොකොන්ට්‍රෝලරයට සාපේක්ෂව එහි ක්‍රියාකාරී වේගය වැඩි.            ඔයාල මට කියන්න එපා මම මේකෙ අතීතෙ ගැන කිව්වෙ නෑ කියල. ඒක ඔයාල ඕන නම් කොහෙන් හරි හොයා ගන්න.අනෙක මොකටද අතීතෙ ?.            මයික්‍රොකොන්ට්‍රෝලරයේ ඇතුලන්තය පහත රූප සටහන් 2න් නිරූපනය වේ. බලල ඒකෙ චිත්ත රූපයක් මවල තියා ගන්නකො.මම පැහැදිලි කරන කොට ඔයාලට පස්සෙ තේරුන් යාවි.





            මයික්‍රොකොන්ට්‍රෝලරයට විදුලිය සැපයූ විට එයට සපයා ඇති ක්‍රම ලේඛනය(Program) පරීක්ෂා කර එයට අනුව පියවරෙන් පියවර(Step by step) වැඩ කරයි. ඒ සදහා ලබා දී ඇති ප්‍රදානයන් පරීක්ෂා කර බලා එයට අදාලව ක්‍රමලේඛනයට අනුව අදාල ප්‍රතිදානයන්(Output) ලබා දෙයි. මේ සදහා මෙය මතකයන්(memory)  2ක උපකාර ලබා ගනු ලබයි.මම ඒව ඉංග්‍රිසියෙන්ම දානවා. මොකද ඒව සිංහලෙන් දැන ගෙන වැඩක් නෑ.·         Data memory
·         Program memory
PROGRAM MEMORY            අපි විවිධ ක්‍රමලේඛන ලියන භාෂාවන් වලින් නිර්මාණය වුන ක්‍රම ලේඛනය මයික්‍රොකොන්ට්‍රෝලරයේ ගබඩා කර තබන්නේ මෙම මතකයේය. මෙය ස්ථිර මතකයයි. මෙය බොහෝ විට Flash ROM එකකි.මෙහි ධාරතාවය(Capacity) උපකරණයෙන් උපකරණයට වෙනස් වේ.
DATA MEMORY            මෙය SFR හා GPR යනුවෙන් කොටස් 2කි. මෙහි GPR යනු RAM එක වශයෙන් බාවිතා වන කොටසයි. SFR යනු මයික්‍රොකොන්ට්‍රෝලරයේ නියමිත වැඩ සදහා සකසා ඇති රෙජිස්ටර්(PORTA, PORTB, TRISA, TRISB) වර්ග වේ. දත්ත හැසිරවීමේ පහසුවට මෙම මතකය BANK 1, BANK 2 වශයෙන් කොටස් 2ට බෙදේ.ඔබට අවශ්‍ය රෙජිස්ටරය බාවිතයට ප්‍රථම එම රෙජිස්ටරය අයත් BANK එක select කරන්න අමතක කරන්න එපා.
            ගොඩක් අය මුලින්ම තෝර ගන්නෙ 16F84 . ඒත් මම හිතුවා  16F877a වගේ එකකින් වැඩේ කලා නම් හරි කියල



              මොනවගෙන්ද මේක හැදිල තියෙන්නෙ? මේක ඇත්තටම ඉලෙක්ට්‍රොනික් උපකරන විශාල ප්‍රමාණයක එකතුවක්. මේකෙ තියෙන කුඩාම තැනුම් එකකය රෙජිස්ටර්(Register) කියලා තමයි හදුන්වන්නෙ. මේක හැදිලා තියෙන්නේ Flip flop 8ක් එකතු වෙලා. පහත රූපයෙන් ඒක ඔබට පැහැදිලි වේවි.


              Flip flop කියන්නේ bit 1 ක මතකයක් තියා ගෙන ඉන්න පුලුවන් ඉලෙක්ට්‍රොනික් සැකැස්මක්. හැබැයි clock එක තියෙනකන් විතරයි මේ bit එක තියෙන්නෙ. මේ විදියට bit 8ක් රෙජිස්ටර් එකක තියා ගන්න පුලුවන්. අපි මයික්‍රොකොන්ට්‍රොලර් එක ක්‍රමලේඛනය කරනවා කියන්නේ අපේ වැඩේට හරියන්න මේ රෙජිස්ටර් ටික සකසන එකයි.මේ ආකාරයට විවිධ වැඩ වලට විශේෂ කරපු රෙජිස්ටර් මයික්‍රොකොන්ට්‍රෝලර් එක ඇතුලෙ තියෙනවා. මම කලින් දවසෙ කිව්වා නේද මතකයේ තියෙන SFR , GPR කියාලා මතක කොටස් 2ක් ගැන?. මෙහි SFR කියන්නෙ Special function register කියන එකයි. මෙම රෙජිස්ටර් මයික්‍රොකොන්ට්‍රෝලරයේ සුවිශේෂී වැඩ සදහා බාවිතා කරයි.එනම් ඒවායේ අපට ඕන ඕන විදියට දත්ත පුරවන්න බැහැ. අපි පිටතින් ගන්න දත්ත , වෙනත් ගණිත කර්ම වලින් ගන්න දත්ත අපි GPR හෙවත් General purpose register තුල ගබඩා කරනවා. අපි දැන් මේ රෙජිස්ටර් කිහිපයක් ගැන බලමු.

W REGISTER 

             කරුමෙ කියන්නේ මේ ඇතුලෙ තියෙන රෙජිස්ටර් වලට කෙලින්ම දත්ත හුවමාරු කරන්න බැහැනෙ. ඒ නිසා මේකට අතරමැදි රෙජිස්ටර් එකක් පාවිච්චි කරන්න වෙනවා. හරියට නිකන් ලව් කරන කාලෙ කොල්ල සපෝටර් කෙනෙක්ගෙ අතේ ලියුම් යවනව වගේ. ඔන්න ඕකට තමයි W register එක පාවිච්චි කරන්නෙ.

PROGRAM COUNTER 

             අපි මෙහෙම හිතමුකො....අපි පන දා ගෙන ලියන program එක මයික්‍රොකොන්ට්‍රෝලරයට දැම්මම තියෙන්නෙ පේලි විදියට කියලා.හැම පේලියටම අංකයක් තියෙනවා. ඒ කියන්නෙ ඒක තමයි ඒ පේලියෙ ලිපිනය(Address). අපිට මේ ලිපිනයෙන් ඕන වෙලාවක Access කරන්න පුලුවන්.මෙන්න මේ ලිපිනය තියා ගෙන ඉන්න රෙජිස්ටරය තමයි Program register කියන්නෙ.මෙම ලිපිනය clock pulse එක සමග එකින් එක වැඩි වෙනවා.මේක වෙනස් වන්නේ CALL,RETLW, GOTO, RETURN වගේ Assembly key word බාවිතා කලොත් විතරයි.

ALU REGISTER

             මයික්‍රොකොන්ට්‍රෝලරය තුල සිදු කරන ගණිත කර්ම මෙම රෙජිස්ටරය තුල සිදු කරනවා. එකතු කරීම , ගුණ කිරීම , බෙදීම, අඩු කිරීම වගේම බූලියන් ගණිත කර්මත් BIT SHIFTING , BIT ROTATING , BIT ORIENTED වගේ ඒවත් කරන්න පුලුවන්.මම මේ ගණිත කර්ම වෙනම පෝස්ට් එකක් දාල කියල දෙන්නම්. නැත්තම් ඔයාලට විතරක් නෙවෙයි මටත් පටලැවෙනව.පහත රූප සටහනේ දැක්වෙන්නෙ ALU Register එකේ දළ සැකැස්මක්.


STACK POINTER

            අපි program එකක් ලියන කොට ඒක විවිධ කොටස් වලට බෙදනවා. Main program කියලා අපි හදුන්වන්නෙ අපේ ප්‍රධාන ක්‍රම ලේඛනය. එක තමයි නිතරම වැඩ කරන්නේ. ඊට අමතරව විවිධ ක්‍රියා වලට අදාලව sub routine ලියනවා. උදාහරණයක් ලෙස අපේ main program එක වැඩ කරන වෙලාවෙ මොකක් හරි sensor එකකින්input එකක් එනවා.ඒකට අදාල program එක sub routine එකක් විදියට තමයි ලියන්නේ. ඉතින් අපිට ඕක කරන්න program එකේදී memory එකේ එක එක තැන් වලට පනින්න වෙනව. ඒ වෙලාවට කලින් හිටපු තැන මතක තියා ගන්නෙ මේ stack pointer කියන රෙජිස්ටර් එක. දැන් තේරුනාද? පහත රූපයෙන් ඔයාලට මම කියන දේ තවත් තේරේවි.



TIMERS

            අපේ වැඩ සටහනේ විවිධ අවස්ථා වලදී කාල ගනනය සිදු කර කටයුතු කිරීමට සිදු වෙනවා. එහිදී තමයි මේ timers ඕන වෙන්නේ. මයික්‍රොකොන්ට්‍රෝලරය අනුව එහි තිබෙන timers ගනන හා විවිධ හැකියාවන් වෙනස් වෙනවා. මේවායේ timers ආකාරTIMER 0 ,TIMER  1 විදියට තමයි වෙනස් වෙන්නෙ. මේ එකිනෙකට ගනනය කල හැකි කාල ප්‍රමාණත් වෙනස්. අනෙක මේව දෘඩාංග(Hardware timers). ඒ නිසා Programඑකෙන් මේවා පාලනය කරන්න පුලුවන්. Main program එකට කරදරේකුත් නෑ.මේවා ගැන මම පස්සෙ ආයෙ කියනවා. මොකද මේක පැහැදිලි වෙන්නේ program එකක් කරන ගමන් කියන කොට. ඔයාල කියන්න එපා උඩින් පල්ලෙන් කරනවා කියල හොදේ...

WATCH DOG TIMER
            මේක නම් ටිකක් අමුතුයි. අනෙක් හැම timer එකක්ම වැඩ කරන්නේ system clock එකෙන්. ඒත් මේකට ඇතුලෙම resister , capacitor වලින් හැදුන දෝළකයක් තියෙනවා (RC Oscillator). මේක සක්‍රිය කරන්නෙත් අමුතු විදියට. එනම් මේක onකරන්නෙ program එකේ මුල තියෙන configuration bits හදලා.කලබල වෙන්න එපා.මේව මම හෙමිහිට පැහැදිලි කරන්නම්.මුලින්ම මට ඕන මේක මොකද්ද, මොකටද ගන්නේ , මේක අනෙක් ඒවට වඩා වෙනස් වෙනවද නැද්ද කියල ඔයාල තේරුම් ගන්න එක විතරයි.
            ආ......... මම මේකෙන් මොකද්ද වෙන්නෙ කියලා කිව්වෙ නැහැනෙ. අනේ සමා වෙන්න... මේකෙ වෙන්නෙ මේ රෙජිස්ටරේ පිරුනම සම්පුරණයෙන්ම program එකrestart වෙනවා.ඇත්තටම මේක මොකටද? අපි හිතමු දිගින් දිගටම එකම program එක වැඩ කරනවා කියලා. අපිට මෙක කරන්න වෙන්නෙ program එක  එක පාරක් වැඩ කරල ඉවර උනාම මුලට යන්න කියල විධානයක් ලියල. ඒත් අපිට මේ timer එක යොදා ගෙන ඒක කරන්න පුලුවන්. අපි මේක සකසනවා program එකේ තරමට. එතකොට හරි නේද?Program එක run වෙලා ඉවර වෙන කොට watch dog timer එකත් පිරෙනවා. ඊළගටrestart වෙනව.මේකෙන් අපිට වාසියක් තියෙනවා. එකම program එක නැවත නැවත වැඩ කරන්න ලිව්ව නම් මයික්‍රොකොන්ට්‍රොලර් එක හිර (struck) වෙන්නත් පුලුවන්. මේකෙන් නිතර නිතර restart වෙන හින්ද එක වෙන්නෙ නෑ.

STATUS REGISTER


            මේක ගොඩක් යොදා ගන්නේ ALU register එකත් එක්ක. ALU register එකේ ගණිත කර්ම කරන කොට එවායේ විවධ දත්තයන් ගබඩා කරන්නේ මේකෙ. ගණිත කර්මයේ උත්තරය 0 ද වගේ ඒව. තවත් වැඩක් තමයි අර මම මුලින් කිව්වෙ Bank selectකරන්න වෙනවා කියල.ඒක කරන්නෙ මේකෙ 5 වෙනි bit එකෙන්.පහත රූපයෙන් එක ඔයාලට තවත් ඒක තේරෙවි.


අපි ඉගෙන ගන්න electronics analog හා digital කියල කොටස් 2කට බෙදෙනවා. Analog කියන්නෙ විද්‍යුත් සංඥාවක් 0 සිට යම් අගයක් දක්වා සන්තතික ලෙස වෙනස් වීමයි. උදාහරණයක් ලෙස 0 සිට 5 දක්වා වෝල්ටීය තාවය වෙනස් වේ නම් එහි 0,0.5, 1, 1.02, 3, 3.1, 4.9, 5ලෙස 5 දක්වා ඕනෑම අගයක් ගත හැක.
            එහෙත් digital electronics වලදී එසේ නොවේ.එහි ඇත්තේ අගයන් 2ක් පමණි. එනම් on හා off පමණි. 0 ත් 5ත් අතර ක්‍රියා කරයි නම් එහි ඇත්තේ 0ත් 5ත් පමණි.අද කාලයේ ඇති electronics පුනරුදයට බෙහෙවින් digital electronics වල දියුණුව බලපා ඇත.digital electronics වලදී සියලුම දත්ත 1හා 0න් ලබා දෙයි.එනම් එයට ද්වීමය කේත(Binary code) ක්‍රමය බාවිතා කරයි.
                Digital electronics වල මූලික සැකැස්ම තාර්කික ද්වාර (Logic gate) වේ.Digital circuits, IC, micro controllers මෙම gates එකතු වීමෙන් සෑදී ඇත.මෙමgates AND, OR, NOT, NAND, NOR, XOR යනුවෙන් වේ.මේවායෙන් AND, OR හාNOT gates මූලික ඒවා වේ.පහත රූපයෙන් දැක්වෙන්නේ ඒවායේ සංකේතයන් සහ ගණිතමය ස්වරූපයයි.

      මෙම සියලුම ද්වාර NAND gate යොදාගෙන සෑදිය හැක.එහිදී NAND gatesකිහිපයක් යොදා ගත යුතුයි.පහත රූපයේ දැක්වෙන්නේ එසේ කරන ආකාරයයි.


දැන් අපි බලමු මේ gates හදන්නේ කොහොමද කියල. ඇත්තෙන්ම මේව හදන්න උපයෝගී කර ගන්නෙ අර්ධ සන්නායකයි (Semi-conductors). මේවාට යොදා ගන්නේDiode හා transistors වේ.මේ රූපෙ බලන්නකෝ.



මේ ඔක්කොම gates, transistors පමණක් යොදා ගෙන සෑදිය හැක. මේ රූපෙන් පෙන්නෙ ඒක.බලන්නකො....



Digital logic circuits කොටස් 2කි.
                        1Combinational logic circuits
                        2. Sequential logic circuits
                Combinational logic circuits කියන්නෙ gates යොදා ගෙන ප්‍රතිදානයේ විවිධ වෙනස් කම් කර ගැනීමයි.එහිදී දත්ත ගබඩා කර ගැනීමක් නැත.නමුත් Sequential logic circuits වල Combinational logic circuits එකකට memory elementsඑකක් සම්බන්ධ කර ඇත.මේක බලන්නකෝ...


       මේ රූපයෙන් දැක්වෙන පරිදි circuit එකට මුලින්ම ලබා දෙන සංඥාව හා memory elements  එකෙහි ඇති දත්තයන් combinational logic circuit එකට ලබා දේ.එමcircuit එකෙන් සංඥාව යම් වෙනස් කිරීමක් කරයි. ප්‍රතිදානය ලබා දේ.නමුත් එවිටම එම ප්‍රතිදානය memory elements එකේ ගබඩා කිරීමක්ද කරයි.ඊළග ප්‍රතිදානය ලබා දෙන විට එම ගබඩා කළ දත්තයද උපාකාරී කර ගනු ලැබේ.මෙම ක්‍රියාව චක්‍රයක් ආකාරයට සිදු වේ.මෙහි විශේෂ්‍යත්වය වන්නේ ප්‍රතිදානය සුලු වේලාවක් ගබඩා කර ගැනීමේ හැකියාවයි.මෙම කාලය clock cycle එකක් වේ.මෙසේ සෑදෙන පරිපථ flip flopවේ.මෙම flip flop circuits, gates යොදා ගෙන සැදිය හැක.
            අද නිකන් පාඩම දිග වැඩිද මන්දා....ඒත් කරන්න දෙයක් නෑ. කරන්නම වෙනවා.අපි විවේකයක් ගන්නත් එක්ක මේ සතියෙ මට වුන වැඩක් කියන්නම්.මම ගෙදර යන්න කොළඹ ඉදල ගාල්ලට එන කොට රෑ 10.30යි. බද්දෙගම බස් එක ගිහින්.මගේ අතේ තිබුනේ රුපියල් 40.00යි. මම දැන් කරන්නෙ මොකද්ද කියලා කල්පනා කරන කොට අපේ ගමේ අයියා කෙනෙක් හම්බ වුනා.මට එයා කිව්වා එයාගෙ තාත්ත එනවා බයිසිකලෙන් එයා එක්ක යමු කියලා.මටත් මාර happy. ඔන්න පැයක් විතර යන කොට ආවා.බද්දෙගම ඉදලා ගාල්ලට එන්න පැයක් විතර යනවා.කිලොමීටර් 25ක් විතර තියෙනවා. අනෙක එදා මාර වැස්ස.අර අයියා තාත්තට කිව්වා අපේ පැත්තෙ මල්ලි කෙනෙක් ඉන්නව දාගෙන යමු කියාලා. තාත්ත කියාපි මේකෙ යන්න බෑ මේ රෑ 3 දෙනෙක් දා ගෙන ගිහින් මොනවා හරි වුනොත් අපිත් කොට උඩ කියලා. මොනවා කරන්නද මම ඒ අයියාට යන්න කියලා.මිනිහටත් හිතට අමාරුයි.මම පයින් එනවා කියලා හිතා ගෙන පයින් ආවා.හැබැයි මාව බයිසිකල් 2කින් සැලකිය යුතු දුරක් එක්ක ආවා. ඒ අයට මගේ ප්‍රණාමය.කොහොම වුනත් ගෙදර එන කොට උදේ 2.30යි.මොනවා කරන්නද මිනිස්සු විවිධාකාරයි නේද?
            ආ දැන් ආයෙ පාඩමට එමු......
            අපි flip flop ගැනනෙ කථා කලේ. Flip flop තියෙනවා වර්ග ගානක්. පහත රූපය බලන්නකෝ.


පහත රූප සටහනෙන් එම flip flop වල කාර්යය හා gate වලින් ඒවා නිර්මාණය වන ආකාරය දැක්වේ.හොදට බලා තේරුම් ගන්න බලන්න.


Tuesday, May 13, 2014

DCCN Labe Assessment 


Labe Assessment 01 in DCCN



Labe Assessment 02 in DCCN




Labe Assessment 03 in DCCN




Labe Assessment 04 in DCCN



Labe Assessment 05 in DCCN




Monday, March 31, 2014

How to connecting mysql to netbens step by step


Contents:

  1. Creating a Database Using MySQL

  2. Making a Connection to MySQL Database

  3. Creating a Table

  4. Inserting a Sample Data

  5. Related references




Before we proceed to the next tutorial, upgrading our skill level, we would like to recap the NetBeans and MySQL database related thingy. We start learning to develop Java GUI application and then make a connection to a database using Java DB (Derby). Then we will try to change the database to MySQL while retaining other aspects of the Java GUI application.  During the process in completing the Java GUI application, we have learned a lot of things regarding the Java technologies and at the same time got familiar with NetBeans 6.x.x. We will try to developed Java application up to the web applications while experiencing all the related Java technologies. Stay tune!

Creating a Database

Firstly let create a new database by using the following SQL statement through MySQL Command Line Client Tool. In this exercise, our database name will beMycompany. Take note that MySQL is not case sensitive. If you want to retain the case sensitiveness, try using the double quotes. We found that using the double quotes also not working all the times.


CREATE DATABASE Mycompany;


Making a Connection

For the next steps, we are using the NetBeans. Launch NetBeans. Click Services tab > expand Database node > expand Drivers node > select MySQL (Connector/J driver) > right click mouse > select Connect Using.




Use the following connection string and key in the username as root and its password. Click OK.

jdbc:mysql://localhost:3306/mycompany


If the connection to the database was established successfully, it will be confirmed as shown in the following Figure. Click OK.


Next, expand the connection node as shown below. You can see the Tables, Views and Procedures folders. These are common database objects that act as containers for other database objects that will be created later.


Creating a Table

Next, execute the following SQL script to create a table. Select the database connection node > right click mouse > select Execute Command to launch SQL query editor.

  

The following table summarized the table that we want to create. You can create the table shown in the Table using the following SQL script. Copy, paste and execute the following SQL script.

The structure for a Employees table
Column name
Data type
Constraints
userID
INT UNSIGNED
NOT NULL PRIMARY KEY
name
CHAR(10)
NOT NULL UNIQUE INDEX
lastName
VARCHAR(30)
 -
firstName
VARCHAR(30)
 -
office
CHAR(2)
NOT NULL

CREATE TABLE IF NOT EXISTS Employees(
   empl_id INT,
   empl_first_name VARCHAR(32) NOT NULL,
   empl_last_name VARCHAR(32) NOT NULL,
   empl_addr_street VARCHAR(32) NOT NULL,
   empl_addr_city VARCHAR(32) NOT NULL,
   empl_addr_zip VARCHAR(10) NOT NULL,
   empl_addr_state VARCHAR(2) NOT NULL,
   empl_dept_id VARCHAR(10) NOT NULL,
   empl_start_date DATE NOT NULL,
   empl_position VARCHAR(5) NOT NULL,
   empl_birth_date DATE NOT NULL,
   PRIMARY KEY (empl_id)
) ENGINE=innodb;

The following Figure shows the SQL script in the SQL query editor/SQL Command editor.


Make sure the connection to the correct database as shown in the following Connection: text field.


Next, click the Run SQL button () or Ctrl+Shift+E to execute the SQL script and notice the progress in the Output window at the bottom.


Next, expand the Tables > employees. MySQL is not case sensitive. If you want to retain the case sensitiveness, use double quotes.


The Employees table contains the following columns:

  • empl_id:  The employee identifier number, which uniquely identifies each employee and is the primary key for these records
  • empl_first_name and empl_last_name:  The employee's first and last names
  • empl_addr_street, empl_addr_city, empl_addr_zip, and empl_addr_state:  The employee's complete address
  • empl_dept_id:  The identifier, a foreign key reference to a row in the Departments table which will be used for the department in which the employee works
  • empl_start_date:  The employee's start date with the company
  • empl_position:  The identifier, a foreign key reference to a Positions table record which will be used for the employee's current job or position
  • empl_birth_date:  The employee's date of birth

Verify our task by issuing the following SQL statement (describe a table).

DESC Employees;


The following Tables list MySQL numerical and character data types information. A complete information can be found in MySQL documentation and you can also download it for offline reading.

Numeric types in MySQL
TINYINT
Whole 7-bit numbers in the range -128 to 127.
SMALLINT
Whole 8-bit numbers in the range -32758 to 32,757.
MEDIUMINT
Whole 16-bit numbers in the range -8,388,608 to 8,388,607.
INT
Whole 32-bit numbers in the range -2,147,483,548 to 2,147,483,547.
BIGINT
Whole 64-bit numbers in the range -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
DECIMAL(p,s)
Decimal values with s as the scale and p as the precision.
DOUBLE(p,s)
Double-precision values with s as the scale and p as the precision.
FLOAT(p)
Floating point numbers with a precision of 8 or less.

Character types for MySQL
CHAR(n)
Fixed-length character type that holds exactly n characters. Shorter strings are padded with spaces to n characters.
NCHAR(n)
Same as CHAR, except for Unicode strings.
VARCHAR(n)
Variable-length strings that may store up to n characters. Any excess characters are discarded.
NVARCHAR(n)
Same as VARCHAR, except for Unicode strings.

Inserting a Sample Data

Next, let insert a record by running the following SQL statement.
INSERT INTO Employees VALUES(
'1234','Jodie','Foster','45th Street, Level 3','New York','32000',
'NY','IT','2008-07-04','Dir','1970-08-05');

Then, verify our task by issuing the following SQL statement.

SELECT * FROM Employees;


How to Embed a SQL Query in Microsoft Excel

This article will help users to embed SQL Query in Excel 2010 and create a dynamic connection in Excel.




  1. Embed a SQL Query in Microsoft Excel Step 1.jpg
    1
    Go to Data tab and select Find Other Sources as shown in the screen shot below.
  2. Embed a SQL Query in Microsoft Excel Step 2.jpg
  3. 2
    Select “From Data Connection Wizard” in the drop down.
  4. Embed a SQL Query in Microsoft Excel Step 3.jpg
    3
    Data Connection Wizard will open. Select “ODBC DSN” from the available option and click “Next”.
  5. Embed a SQL Query in Microsoft Excel Step 4.jpg
    4
    Connect to ODBC Data Source window appears. Where a list of database available in our organization will be displayed. Select the appropriate database and click on “Next”.
  6. Embed a SQL Query in Microsoft Excel Step 5.jpg
    5
    Select Database and Table window appears. We can select the database and the table from where we wish to pull the data. So, select the database and table as appropriate in our case.
  7. Embed a SQL Query in Microsoft Excel Step 6.jpg
    6
    Select Finish in “Save Data Connection File and Finish” window. This window will pull up the File Name based on our selection in previous screens.
  8. Embed a SQL Query in Microsoft Excel Step 7.jpg
    7
    Import Data window appears where we can select options as per our need and click OK.
  9. Embed a SQL Query in Microsoft Excel Step 8.jpg
    8
    Select “From Data Connection Wizard” in the drop down.
  10. Embed a SQL Query in Microsoft Excel Step 9.jpg
    9
    Go to Data tab and Click on Connections. Click on Properties in the following window.
  11. Embed a SQL Query in Microsoft Excel Step 10.jpg
    10
    Go to Definitions tab in the following window and write SQL query in “Command Text” and Click OK. Excel will display the result as per the query.
  12. Embed a SQL Query in Microsoft Excel Step 11.jpg
    11
    Now go to Microsoft Excel and validate if the results are as per the SQL Query written.

OAuth authorization server